Find the route as soon as the URL is parsed #499
Merged
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.
the TL;DR is that this PR makes it so that a request is routed as soon as the URL is parsed.
The long version is that it makes multiple changes to multiple parts of the framework, these changes are as follows:
using routing_search_result
andusing routing_handle_result
.on_url
callback. (from theon_message_complete
callback)on_method
callback that executes when the method is parsedto_request()
method by immediately assigning any parsed data to a request object owned by the parser. (this is fine since the parser is owned by and exist for the lifetime of the HTTP connection)process_url()
function to call a connection'shandle_url()
. (explained below)handle_url()
function to call the router and behave according to the result. (i.e returning a response in case of a404
or405
)routing_handle_result
property in order to check whether or not a route was found. (could be a good idea to replace with a boolean returned fromhandle_url()
in the application)handle()
method into 2 separate methods, one that deals with only finding a route and another that does the actual handling.The other changes are either documentation related or only there to adapt to the changes above.
This PR closes #493 and make an implementation for #397 possible.