Моя функция
Код: Выделить всё
import azure.functions as func
from pydantic import ValidationError
from utils.auth import with_auth, decor2
import logging
project_bp = func.Blueprint()
@with_auth
@project_bp.route(route="project", auth_level=func.AuthLevel.ANONYMOUS, methods=["GET"])
def project(req: func.HttpRequest) -> func.HttpResponse:
try:
return func.HttpResponse(f"Hello all possible worlds! ---- --- -- *", status_code=200)
except ValidationError as e:
return func.HttpResponse(f"Validation error: {e}", status_code=400)
Код: Выделить всё
def with_auth(func):
# Function runs until here
# @wraps(func)
def wrapper(*args, **kwargs):
# Access the request object (req) here
req: az.HttpRequest = kwargs["req"]
for k in req.headers.values():
print(k) # Prints nothing...
# If authenticated, call the original function
return func(*args, **kwargs)
return wrapper
Пропробовал множество примеров отсюда, но ни один из них не работал должным образом.
Подробнее здесь: https://stackoverflow.com/questions/790 ... -arguments