-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add implementation of PRESTO middleware. (#73)
* Add implementation of PRESTO middleware and tests for it. * Address review comments. * Recover log statements which still has sense.
- Loading branch information
Showing
13 changed files
with
475 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
{.push raises: [].} | ||
|
||
import strutils | ||
import std/strutils | ||
|
||
const | ||
PrestoName* = "nim-presto" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# | ||
# REST API framework implementation | ||
# (c) Copyright 2021-Present | ||
# Status Research & Development GmbH | ||
# | ||
# Licensed under either of | ||
# Apache License, version 2.0, (LICENSE-APACHEv2) | ||
# MIT license (LICENSE-MIT) | ||
|
||
{.push raises: [].} | ||
|
||
import chronos, chronos/apps/http/httpserver | ||
import "."/[route, servercommon, serverprivate] | ||
export httpserver, servercommon, serverprivate | ||
|
||
proc new*( | ||
t: typedesc[RestServerMiddlewareRef], | ||
router: RestRouter, | ||
errorHandler: RestRequestErrorHandler = nil): HttpServerMiddlewareRef = | ||
|
||
proc middlewareCallback( | ||
middleware: HttpServerMiddlewareRef, | ||
request: RequestFence, | ||
handler: HttpProcessCallback2): Future[HttpResponseRef] {. | ||
async: (raises: [CancelledError], raw: true).} = | ||
let restmw = RestServerMiddlewareRef(middleware) | ||
restmw.nextHandler = handler | ||
processRestRequest[RestServerMiddlewareRef](restmw, request) | ||
|
||
let middleware = | ||
RestServerMiddlewareRef(router: router, errorHandler: errorHandler, | ||
handler: middlewareCallback) | ||
HttpServerMiddlewareRef(middleware) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.