def service(func):
"""
Make sure this is the first/closest @wrapper on your service function
Note that this decorator tags the original function with meta and new arguments.
The real url-->fn() registeration happens in __init__.py autodiscover() because of @url.
"""
@csrf_exempt # setting wrapper.csrf_exempt = True, consulted by CsrfViewMiddleware
def wrapper(req, *args, **kwargs):
response = ExpressResponse()
request = ExpressRequest(req)
func(request, response, *args, **kwargs) # all service functions should have this signature.
return response._res
wrapper.__name__ = func.__name__
wrapper.__doc__ = func.__doc__
wrapper.__module__ = func.__module__
# base entrypoint
wrapper._path = func.__name__
return wrapper
# use only on a Django ORM Model cls
评论列表
文章目录