|
|
|
@ -27,15 +27,20 @@ export default class Kernel extends AppClass {
|
|
|
|
|
protected postflight: Collection<Module> = new Collection<Module>()
|
|
|
|
|
|
|
|
|
|
public async handle(request: Request): Promise<Request> {
|
|
|
|
|
const logger = this.make(Logging)
|
|
|
|
|
|
|
|
|
|
for ( const module of this.preflight.toArray() ) {
|
|
|
|
|
logger.verbose(`Applying pre-flight HTTP kernel module: ${module.constructor.name}`)
|
|
|
|
|
request = await module.apply(request)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( this.inflight ) {
|
|
|
|
|
logger.verbose(`Applying core HTTP kernel module: ${this.inflight.constructor.name}`)
|
|
|
|
|
request = await this.inflight.apply(request)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( const module of this.postflight.toArray() ) {
|
|
|
|
|
logger.verbose(`Applying post-flight HTTP kernel module: ${module.constructor.name}`)
|
|
|
|
|
request = await module.apply(request)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -54,6 +59,7 @@ export default class Kernel extends AppClass {
|
|
|
|
|
let found_index = this.preflight.find((mod: Module) => mod instanceof other)
|
|
|
|
|
if ( typeof found_index !== 'undefined' ) {
|
|
|
|
|
this.preflight = this.preflight.put(found_index, this.make(module))
|
|
|
|
|
return this
|
|
|
|
|
} else {
|
|
|
|
|
found_index = this.postflight.find((mod: Module) => mod instanceof other)
|
|
|
|
|
}
|
|
|
|
@ -75,6 +81,7 @@ export default class Kernel extends AppClass {
|
|
|
|
|
let found_index = this.preflight.find((mod: Module) => mod instanceof other)
|
|
|
|
|
if ( typeof found_index !== 'undefined' ) {
|
|
|
|
|
this.preflight = this.preflight.put(found_index + 1, this.make(module))
|
|
|
|
|
return this
|
|
|
|
|
} else {
|
|
|
|
|
found_index = this.postflight.find((mod: Module) => mod instanceof other)
|
|
|
|
|
}
|
|
|
|
@ -82,7 +89,6 @@ export default class Kernel extends AppClass {
|
|
|
|
|
if ( typeof found_index !== 'undefined' ) {
|
|
|
|
|
this.postflight = this.postflight.put(found_index + 1, this.make(module))
|
|
|
|
|
} else {
|
|
|
|
|
console.log(this.preflight, this.postflight)
|
|
|
|
|
throw new KernelModuleNotFoundError(other.name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|