Adding HTTP PATCH method to modify existing resources

Added support of PATCH HTTP method that will be implemented
the same way as current PUT method.

Partially-Implements: blueprint api-for-objects-update

Change-Id: I3cd7cd7e03fa424d5bd47244dc4d58462b8c859e
This commit is contained in:
Andrey Pavlov 2015-08-10 11:04:20 +03:00
parent 39f964e2e9
commit 370a8f3992

View File

@ -49,6 +49,9 @@ class Rest(flask.Blueprint):
def delete(self, rule, status_code=204):
return self._mroute('DELETE', rule, status_code)
def patch(self, rule, status_code=202):
return self._mroute('PATCH', rule, status_code)
def _mroute(self, methods, rule, status_code=None, **kw):
if type(methods) is str:
methods = [methods]
@ -85,7 +88,7 @@ class Rest(flask.Blueprint):
flask.request.headers['X-Roles'].split(','),
request_id=req_id)
context.set_ctx(ctx)
if flask.request.method in ['POST', 'PUT']:
if flask.request.method in ['POST', 'PUT', 'PATCH']:
kwargs['data'] = request_data()
try: