I am creating a proxy with flask-restplus and I want to handle all http methods with one function
for example:
this is my restplus class
@api.route('/', defaults={'path': ''})
@api.route('/<path:path>')
class Access(Resource):
@ip_limiter
@path_limiter
def get(self,path):
data = request.json
ip=request.remote_addr
method=request.method
response = AccessService.get_new_access(data,path,ip,method)
return response
@ip_limiter
@path_limiter
def post(self,path):
data = request.json
ip=request.remote_addr
method=request.method0
response = AccessService.get_new_access(data,path,ip,method)
return response
@ip_limiter
@path_limiter
def put(self,path):
data = request.json
ip=request.remote_addr
method=request.method
response = AccessService.get_new_access(data,path,ip,method)
return response
@ip_limiter
@path_limiter
def delete(self,path):
data = request.json
ip=request.remote_addr
method=request.method
response = AccessService.get_new_access(data,path,ip,method)
return response
Is there a way to transform that in something like this?
@api.route('/', defaults={'path': ''})
@api.route('/<path:path>')
class Access(Resource):
@ip_limiter
@path_limiter
def all(self,path):
data = request.json
ip=request.remote_addr
method=request.method
response = AccessService.get_new_access(data,path,ip,method)
return response
is this possible with flask-restplus or do I have to find a workaround?