Skip to content
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

revel.Route.TreePath remove http method #1212

Open
zuoRambo opened this issue Jul 26, 2017 · 5 comments
Open

revel.Route.TreePath remove http method #1212

zuoRambo opened this issue Jul 26, 2017 · 5 comments

Comments

@zuoRambo
Copy link

# routes file
...
GET /  App.Index
...

when i access http://localhost:9000/ with POST method, the server return response with status code 404.

I think it should be 405(method not allowed)

@notzippy
Copy link
Collaborator

The challenging part with that is Revel registers it as a miss on the router path since the route path starts with matching the method and working its way up. So when it looks up your request it looks for /GET/ to find App.Index and you could have a second like /PUT/ pointing to App.Index2 So in that case it hits it as a miss.

What could be done is that I add another route without the method (for methods which are defined) and if the first lookup fails then a second lookup could occur which may find a match and if a match is found we could set the status code to 405. Do you think that would work for you ?

@zuoRambo
Copy link
Author

I think the point is how to to define router match and HTTP Status Code 405.

how about the pseudo-code below

if match PATH
    if match METHOD
        do action
    else
        return 405
else
    return 404

@notzippy
Copy link
Collaborator

There is a domain routing feature I have been eyeing that this could be implemented in. I added a reference back to this from there.

@zuoRambo
Copy link
Author

Feature/domain routing #536 ? It looks like is not releated to my idea. 😢

@notzippy
Copy link
Collaborator

It has to do with changes to the router, I am putting them both together in that aspect.
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants