diff --git a/adonis-typings/request.ts b/adonis-typings/request.ts index 2827fc6..10f0390 100644 --- a/adonis-typings/request.ts +++ b/adonis-typings/request.ts @@ -547,6 +547,7 @@ declare module '@ioc:Adonis/Core/Request' { allowMethodSpoofing: boolean, getIp?: ((request: RequestContract) => string), trustProxy: (address: string, distance: number) => boolean, + enableAsyncHttpContext?: boolean, } /** diff --git a/src/Server/index.ts b/src/Server/index.ts index 6af8a0b..b527d17 100644 --- a/src/Server/index.ts +++ b/src/Server/index.ts @@ -122,8 +122,10 @@ export class Server implements ServerContract { } private getAsyncContext (ctx: HttpContextContract): InternalAsyncHttpContext | null { - // TODO: check if async context is activated, return null if not. - return new InternalAsyncHttpContext(ctx) + if (this.httpConfig.enableAsyncHttpContext) { + return new InternalAsyncHttpContext(ctx) + } + return null } /**