Watch
1
0
Fork
You've already forked arc
0
forked from hesabix/arc
arc/hesabixAPI/app/core/calendar_middleware.py
2026-04-14 19:34:55 +03:30

14 lines
490 B
Python
Executable file

from __future__ import annotations
from fastapi import Request
from .calendar import get_calendar_type_from_header, CalendarType
async def add_calendar_type(request: Request, call_next):
"""Middleware to add calendar type to request state"""
calendar_header = request.headers.get("X-Calendar-Type")
calendar_type = get_calendar_type_from_header(calendar_header)
request.state.calendar_type = calendar_type
response = await call_next(request)
return response