This commit is contained in:
2020-04-09 21:12:36 +02:00
parent bc50897afc
commit 2dc969a47d
5 changed files with 406 additions and 27 deletions

View File

@@ -7,7 +7,9 @@ export default abstract class Handler {
private _method_handlers: Record<string, Function> = {};
protected register_handler (f: Function, method?: string): void {
if (typeof method === 'undefined') { this._handlers.push (f); }
if (typeof method === 'undefined') {
this._handlers.push (f);
}
else {
const m = method.toUpperCase ();
if (typeof this._method_handlers[m] !== 'undefined')
@@ -16,7 +18,10 @@ export default abstract class Handler {
}
}
private async run_method_handler (method: string, t: Transaction): Promise<void> {
private async run_method_handler (
method: string,
t: Transaction
): Promise<void> {
const m = method.toUpperCase ();
if (typeof this._method_handlers[m] !== 'undefined')
await this._method_handlers[m] (t);