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.
20 lines
506 B
20 lines
506 B
from fastapi import Depends, FastAPI, Header, HTTPException
|
|
|
|
from .routers import items, users
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
async def get_token_header(x_token: str = Header(...)):
|
|
if x_token != "fake-super-secret-token":
|
|
raise HTTPException(status_code=400, detail="X-Token header invalid")
|
|
|
|
|
|
app.include_router(users.router)
|
|
app.include_router(
|
|
items.router,
|
|
prefix="/items",
|
|
tags=["items"],
|
|
dependencies=[Depends(get_token_header)],
|
|
responses={404: {"description": "Not found"}},
|
|
)
|
|
|