Hi, it would be great to be able to set the return status to 201 and provide the Location HTTP header in the response. This would make Chalice much more useful to create RESTFul APIs.
Thanks,
Lars
Not currently possible, but I'd like to add this. Marking as a feature request.
Next to 201, I'd also like to return 202, and 204 as well as 405, 410, 423, ...
For 4xx and 5xx, maybe can be as simple as raise HttpError(status_code, description) ?
@stannie, 405 has just been addressed in #160
The latest version of 0.6.0 now makes this possible. The default JSON response is still preserved, but you can return a chalice.Response instance which allows you to specify custom headers including Location:
from chalice import Chalice, Response
app = Chalice(app_name='custom-response')
@app.route('/')
def index():
return Response(body='',
status_code=201,
headers={'Location': 'https://...'})
Let me know if you have any questions/feedback about this feature.
Most helpful comment
The latest version of 0.6.0 now makes this possible. The default JSON response is still preserved, but you can return a chalice.Response instance which allows you to specify custom headers including Location:
Let me know if you have any questions/feedback about this feature.