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

Invalid method returns 404 not 405 #257

Open
akrabat opened this issue Sep 17, 2017 · 4 comments
Open

Invalid method returns 404 not 405 #257

akrabat opened this issue Sep 17, 2017 · 4 comments

Comments

@akrabat
Copy link
Member

akrabat commented Sep 17, 2017

Given an API Gateway set up to only accept GET, if I try to POST to it, I get a 404 back.

I should get a 405 as the resource exists (i.e. was found), but I'm not allowed to access it with this method.

$ wsk api create /hello / GET hello
ok: created API /hello/ GET for action /_/hello
https://service.eu.apiconnect.ibmcloud.com/gws/apigateway/api/d12...b12/hello/

$ curl -I -X POST https://service.eu.apiconnect.ibmcloud.com/gws/apigateway/api/d12..b12/hello
HTTP/1.1 404 Not Found
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
Date: Sun, 17 Sep 2017 19:07:37 GMT
Server: openresty
Content-Length: 62

{"status":404,"message":"Error: Whoops. Verb not supported."}
@mhamann
Copy link
Member

mhamann commented Sep 17, 2017

If you implemented a route in Express that had a GET but no POST, what would you get? I believe the Method Not Allowed error is for a method + route that does exist, but has been disabled for some reason.

@akrabat
Copy link
Member Author

akrabat commented Sep 17, 2017

I don't use JS, so I haven't a clue what Express does.

The specification seems quite clear that 405 is to be used when the method is not supported by the resource (/hello in this case):

The 405 (Method Not Allowed) status code indicates that the method
received in the request-line is known by the origin server but not
supported by the target resource.

@akrabat
Copy link
Member Author

akrabat commented Sep 17, 2017

Googling, I see that Express doesn't do this because it's too complicated to do in their codebase: expressjs/express#1895 (comment)

API Gateway shouldn't have this problem as it knows all the valid methods for any given path as we have to create them... (of course, I'm making assumptions here!)

@AlanduzzZ
Copy link

any updates?

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

3 participants