@@ -487,11 +487,12 @@ proc handleContext*(app: Prologue, ctx: Context) {.async, gcsafe.} =
487487
488488 logging.debug ($ (ctx.response))
489489
490- proc handleRequest * (app: Prologue , nativeRequest: NativeRequest , ctx: Context ): Future [void ] {.gcsafe .} =
490+ proc handleRequest * (app: Prologue , nativeRequest: NativeRequest , ctxTyp: typedesc [ Context ] ): Future [void ] {.gcsafe .} =
491491 # # Handles the native request and sends response to the client.
492492 var request = initRequest (nativeRequest)
493493 handleNativeRequest (request)
494494
495+ var ctx = new ctxTyp
495496 init (ctx, request, initResponse (HttpVer11 , Http200 ), app.gScope)
496497 extend (ctx)
497498 result = handleContext (app, ctx)
@@ -500,7 +501,6 @@ proc run*(app: Prologue, ctxTyp: typedesc[Context]) =
500501 # # Starts an Application.
501502
502503 # assert ctx != nil, "The memory of `ctx` must be allocated!"
503- var ctx = new ctxTyp
504504 app.gScope.router.compress ()
505505
506506 # start event
@@ -528,7 +528,7 @@ proc run*(app: Prologue, ctxTyp: typedesc[Context]) =
528528
529529
530530 app.serve (proc (nativeRequest: NativeRequest ): Future [void ] {.gcsafe .} =
531- result = handleRequest (app, nativeRequest, ctx ))
531+ result = handleRequest (app, nativeRequest, ctxTyp ))
532532
533533
534534proc run * (app: Prologue ) {.inline .} =
0 commit comments