Skip to content

Commit ed00fd9

Browse files
committed
fix #150
1 parent a0be302 commit ed00fd9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/prologue/core/application.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

534534
proc run*(app: Prologue) {.inline.} =

0 commit comments

Comments
 (0)