This repository was archived by the owner on Jan 5, 2024. It is now read-only.
Flexible complex routes#31
Merged
albertodebortoli merged 11 commits intoMay 18, 2021
Merged
Conversation
added 10 commits
May 10, 2021 15:22
|
|
||
| let context = _MiddlewareContext(requestContext: requestContext, | ||
| responseContext: responseContext) { | ||
| responseContext: responseContext, |
Member
There was a problem hiding this comment.
This could be formatted better.
albertodebortoli
approved these changes
May 14, 2021
jnewc
approved these changes
May 17, 2021
| public protocol MiddlewareContext { | ||
| var requestContext: MiddlewareRequestContext { get } | ||
| var responseContext: MiddlewareResponseContext { get } | ||
| var notFoundHandler: HandlerClosure? { get } |
Contributor
There was a problem hiding this comment.
I'm not sure I like this as it circumvents the standard middleware pattern and is letting NIO implementation details bleed into the context interface - the middleware shouldn't need to know about special HTTP handling cases; the purpose of middleware is to be generic enough so as to allow the implementor to cover these cases themself.
No need to hold up the PR for this, but I'll have a think about how the same functionality can be achieved without the interface bleed.
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shock now uses the entire route request (method, path, params, etc) for the key in the internal routing dictionary. This makes complex routes much more flexible, allowing registration of multiple routes with the same
urlPath.This PR:
EquatableandHashablesupport to theMockHTTPRouteenum (and adds copious tests).MockHTTPRouteas the key in thePathHandlerMapping(nowRouteHandlerMapping).notFoundHandlerto theMiddlewareContext.