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.

36 lines
903 B

import {Request} from '../Request.ts'
import Kernel from './Kernel.ts'
import AppClass from '../../lifecycle/AppClass.ts'
/**
* Base class for HTTP kernel modules.
* @extends AppClass
*/
export default class Module extends AppClass {
/**
* 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> {
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 {Kernel} kernel
*/
public static register(kernel: Kernel) {
kernel.register(this).before()
}
}