def _provide_client_handler(self, section, name, kwargs_updator=None):
def _wrapper(func):
@wraps(func)
def _handler(**kwargs):
client_key = self.auth.authenticate(
request.method,
request.url,
request.headers)
client = self.client_class.load(client_key)
if not client:
abort(401)
g.ac_client = client
kwargs['client'] = client
if kwargs_updator:
kwargs.update(kwargs_updator(**kwargs))
ret = func(**kwargs)
if ret is not None:
return ret
return '', 204
self._add_handler(section, name, _handler)
return func
return _wrapper
评论列表
文章目录