MCPcopy
hub / github.com/fluentpython/example-code-2e / decorator

Function decorator

21-async/mojifinder/bottle.py:2691–2699  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

2689 ''' Callback decorator to require HTTP auth (basic).
2690 TODO: Add route(check_auth=...) parameter. '''
2691 def decorator(func):
2692 def wrapper(*a, **ka):
2693 user, password = request.auth or (None, None)
2694 if user is None or not check(user, password):
2695 err = HTTPError(401, text)
2696 err.add_header('WWW-Authenticate', 'Basic realm="%s"' % realm)
2697 return err
2698 return func(*a, **ka)
2699 return wrapper
2700 return decorator
2701
2702

Callers 1

routeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected