mirror of https://github.com/tiangolo/fastapi.git
22 lines
436 B
Python
22 lines
436 B
Python
from typing import List, Union
|
|
|
|
from fastapi import FastAPI, Header
|
|
from pydantic import BaseModel
|
|
|
|
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: CommonHeaders = Header()):
|
|
return headers
|