Files
lib/src/http/routing/Middleware.ts
garrettmills 074a3187eb
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is failing
Add support for jobs & queueables, migrations
- Create migration directives & migrators
- Modify Cache classes to support array manipulation
- Create Redis unit and RedisCache implementation
- Create Queueable base class and Queue class that uses Cache backend
2021-08-23 23:51:53 -05:00

31 lines
884 B
TypeScript

import {Request} from '../lifecycle/Request'
import {ResponseObject} from './Route'
import {Container} from '../../di'
import {CanonicalItemClass} from '../../support/CanonicalReceiver'
/**
* Base class representing a middleware handler that can be applied to routes.
*/
export abstract class Middleware extends CanonicalItemClass {
constructor(
/** The request that will be handled by this middleware. */
protected readonly request: Request,
) {
super()
}
protected container(): Container {
return this.request
}
/**
* Apply the middleware to the request.
* If this returns a response factory or similar item, that will be sent
* as a response.
*
* If this returns `void | Promise<void>`, the request will continue to the
* next handler.
*/
public abstract apply(): ResponseObject
}