Standard libraries that lift up your code.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

46 lines
1.5 KiB

import {Injectable} from '../../di'
import {AppClass} from '../../lifecycle/AppClass'
import {HTTPKernel} from './HTTPKernel'
import {Request} from '../lifecycle/Request'
/**
* Base class for modules that define logic that is applied to requests
* handled by the HTTP kernel.
*/
@Injectable()
export class HTTPKernelModule extends AppClass {
/**
* By default, if a kernel module interrupts the request flow to send a response
* (for example, if an error occurs), subsequent modules are skipped.
*
* However, a module can override this property to be true and its logic will still
* be applied, even after a module has interrupted the request flow.
*/
public readonly executeWithBlockingWriteback: boolean = false
/**
* Returns true if the given module should be applied to the incoming request.
* @param {Request} request
* @return Promise<boolean>
*/
public async match(request: Request): Promise<boolean> { // eslint-disable-line @typescript-eslint/no-unused-vars
return true
}
/**
* Apply the module to the incoming request.
* @param {Request} request
* @return Promise<Request>
*/
public async apply(request: Request): Promise<Request> {
return request
}
/**
* Register this module with the given HTTP kernel.
* @param {HTTPKernel} kernel
*/
public static register(kernel: HTTPKernel): void {
kernel.register(this).before()
}
}