I'm developing a proxy server by using Sanic. (The reason why I chose this framework is that it is so fast and it uses asynchronous event loop.)
So I want to catch all requests to my Sanic server and do some post-processings.
@app.route("/<path:path>", methods = []) # Here is the question point
async def proxy(request: Request, path: str):
// do something
return redirect("...")
I think it is not so good to write all HTTP methods and pass them through methods
parameter. So I want to know if there is a more effective way to allow all HTTP methods to my route.
Thanks in advance.
** Answering my own question
I just have to get all values of the enum HTTPMethod
. I don't understand that I didn't come up with such an easy solution.
@app.route("/<path:path>", methods = list(map(str, HTTPMethod)))
async def proxy(request: Request, path: str):
// do something
return redirect("...")