Before default_dispatcher is called, check the _method parameter and rewrite the value of request.method to the corresponding method, so prepare your own dispatcher and set it with the app.router.set_dispatcher method.
def dispatcher(router, request, response):
method = request.get('_method').upper()
if method in ['HEAD', 'OPTIONS', 'PUT', 'DELETE', 'TRACE']:
request.method = method
return router.default_dispatcher(request, response)
app = webapp2.WSGIApplication([
webapp2.Route('/foo', handler=FooHandler),
], debug=True)
app.router.set_dispatcher(dispatcher)
Recommended Posts