Add support for middleware
This commit is contained in:
@@ -58,18 +58,30 @@ export class HTTPKernel extends AppClass {
|
||||
public async handle(request: Request): Promise<Request> {
|
||||
try {
|
||||
for (const module of this.preflight.toArray()) {
|
||||
this.logging.verbose(`Applying pre-flight HTTP kernel module: ${module.constructor.name}`)
|
||||
request = await module.apply(request)
|
||||
if ( !request.response.blockingWriteback() || module.executeWithBlockingWriteback ) {
|
||||
this.logging.verbose(`Applying pre-flight HTTP kernel module: ${module.constructor.name}`)
|
||||
request = await module.apply(request)
|
||||
} else {
|
||||
this.logging.verbose(`Skipping pre-flight HTTP kernel module because of blocking write-back: ${module.constructor.name}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (this.inflight) {
|
||||
this.logging.verbose(`Applying core HTTP kernel module: ${this.inflight.constructor.name}`)
|
||||
request = await this.inflight.apply(request)
|
||||
if ( !request.response.blockingWriteback() || this.inflight.executeWithBlockingWriteback ) {
|
||||
this.logging.verbose(`Applying core HTTP kernel module: ${this.inflight.constructor.name}`)
|
||||
request = await this.inflight.apply(request)
|
||||
} else {
|
||||
this.logging.verbose(`Skipping core HTTP kernel module because of blocking write-back: ${this.inflight.constructor.name}`)
|
||||
}
|
||||
}
|
||||
|
||||
for (const module of this.postflight.toArray()) {
|
||||
this.logging.verbose(`Applying post-flight HTTP kernel module: ${module.constructor.name}`)
|
||||
request = await module.apply(request)
|
||||
if ( !request.response.blockingWriteback() || module.executeWithBlockingWriteback ) {
|
||||
this.logging.verbose(`Applying post-flight HTTP kernel module: ${module.constructor.name}`)
|
||||
request = await module.apply(request)
|
||||
} else {
|
||||
this.logging.verbose(`Skipping post-flight HTTP kernel module because of blocking write-back: ${module.constructor.name}`)
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
this.logging.error(e)
|
||||
|
||||
Reference in New Issue
Block a user