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

Support PATCH and DELETE HTTP Methods #167

Closed
jbarratt opened this issue Nov 14, 2016 · 3 comments · Fixed by #173
Closed

Support PATCH and DELETE HTTP Methods #167

jbarratt opened this issue Nov 14, 2016 · 3 comments · Fixed by #173
Labels

Comments

@jbarratt
Copy link

I could certainly be missing something, but it doesn't look like PATCH and DELETE methods are supported. They are supported by API Gateway, so it seems reasonable that chalice could have support for them too.

These methods are key for many common RESTful API patterns, which chalice seems ideal for creating.

@jamesls
Copy link
Member

jamesls commented Nov 15, 2016

This should be working. Do you have specific code you can share that demonstrates the issue? Here's what I tried:

@app.route('/delete', methods=['DELETE'])
def deletemethod():
    return {'http-method': app.current_request.method}

@app.route('/patch', methods=['PATCH'])
def patchmethod():
    return {'http-method': app.current_request.method}
$ http DELETE https://.../prod/delete
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 25
Content-Type: application/json
Date: Tue, 15 Nov 2016 01:50:31 GMT
...
{
    "http-method": "DELETE"
}

$ http PATCH https://.../prod/patch
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 24
Content-Type: application/json
Date: Tue, 15 Nov 2016 01:50:36 GMT
...

{
    "http-method": "PATCH"
}

@jbarratt
Copy link
Author

Ah, it may just be an issue with chalice local. Using your test code:

$ chalice local
Serving on localhost:8000
127.0.0.1 - - [14/Nov/2016 21:42:41] code 501, message Unsupported method ('PATCH')
127.0.0.1 - - [14/Nov/2016 21:42:41] "PATCH / HTTP/1.1" 501 -
$ http PATCH http://localhost:8000 
HTTP/1.0 501 Unsupported method ('PATCH')
Connection: close
Content-Type: text/html
Date: Tue, 15 Nov 2016 05:42:41 GMT
Server: BaseHTTP/0.3 Python/2.7.11

<head>
<title>Error response</title>
</head>
<body>
<h1>Error response</h1>
<p>Error code 501.
<p>Message: Unsupported method ('PATCH').
<p>Error code explanation: 501 = Server does not support this operation.
</body>

@jamesls
Copy link
Member

jamesls commented Nov 15, 2016

Thanks for the clarification. I'll get that fixed.

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

Successfully merging a pull request may close this issue.

2 participants