pythonasyncioapiasyncfastapiframeworkjsonjson-schemaopenapiopenapi3pydanticpython-typespython3redocreststarletteswaggerswagger-uiuvicornweb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
486 B
22 lines
486 B
from typing import List, Union
|
|
|
|
from fastapi import FastAPI, Header
|
|
from pydantic import BaseModel
|
|
from typing_extensions import Annotated
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class CommonHeaders(BaseModel):
|
|
model_config = {"extra": "forbid"}
|
|
|
|
host: str
|
|
save_data: bool
|
|
if_modified_since: Union[str, None] = None
|
|
traceparent: Union[str, None] = None
|
|
x_tag: List[str] = []
|
|
|
|
|
|
@app.get("/items/")
|
|
async def read_items(headers: Annotated[CommonHeaders, Header()]):
|
|
return headers
|
|
|