-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support HTTP extensions beyond HTTP 1.1 spec #597
Comments
I agree we should support arbitrary methods. My first thoughts are that we could check for allowed methods by going through methods provided by routes. When a route is added, we can add the method to a hash that is then checked. What do you think? |
On Sat, May 31, 2014 at 12:27:21PM -0700, Sawyer X wrote:
Why not fix the dispatcher to check URL first, then method? That way we could 405 precisely for each entity type within an app. Also it's better HTTP :) Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a clue http://shadowcat.co.uk/blog/matt-s-trout/ http://twitter.com/shadowcat_mst/ Email me now on mst (at) shadowcat.co.uk and let's chat about how our CPAN |
In either case, there must be a new DSL keyword. I suggest
And then we can deprecate all the DSL keywords that correspond to HTTP methods slowly, or move them to a plugin. The problem with @shadowcat-mst 's suggestion of checking the URL first then the method is that we are going to have everything slower just to serve that purpose, which is (correct me if this is wrong) not supposed to be that common of a case. This line in Dancer2::Core::App
will become
since you can't do anything but loop all the routes because of those routes defined using regular expressions. You'll then check the method existence in O(1), but still, the average number of checked routes will grow. I'm more inclined to Sawyer's idea (although it is not an exhaustive check, since we still could throw a 405 from inside if we happen to find the method in that global hash but it was not defined for the matched route, so we could still do without that check) combined with adding the 'route' DSL keyword. What do you think? |
A We will not be deprecating the HTTP method-based keywords. That's for sure. :) That's the main syntax for Dancer and it's not going away. I would research how others have tackled this. We could have used trie except we have regexp paths so that won't work. Caching the methods and routes would help reduce the overhead of every method to every route and we could generate an index when adding new routes. I didn't disagree with @shadowcat-mst. He is correct. I was just looking for a way to reduce the overhead it will introduce. Worth pointing out we don't know how big of a overhead it will be. |
@omar-m-othman |
What about |
(Following on from @shadowcat-mst's comment in #595)
The current Runner, Request and Route classes limit the requests method to only those allowed under the HTTP 1.1 spec. There are extensions to the HTTP spec such as WebDAV, that allow further request types.
The DSL is flexible enough to to allow users to add support keywords for such extensions. Do we want to limit Dancer2 to HTTP 1.1 request methods only ?
Assuming we want this flexibility; what's the best way to implement it?
(As a possibly leading idea; the changes in #595 looks likes it could easily be reworked into standalone Middleware)
The text was updated successfully, but these errors were encountered: