mirror of
https://github.com/fastapi/fastapi.git
synced 2026-10-29 11:14:41 +08:00
15 lines
282 B
Python
15 lines
282 B
Python
from fastapi import FastAPI, Header
|
|
from pydantic import BaseModel
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class ClientHeaders(BaseModel):
|
|
x_client_name: str
|
|
x_client_version: str
|
|
|
|
|
|
@app.get("/items/")
|
|
async def read_items(client: ClientHeaders | None = Header(default=None)):
|
|
return client
|