FastAPI Integration¶
lacme.ext_fastapi ¶
FastAPI integration for lacme ACME certificate management.
Provides :func:acme_challenge_router for serving HTTP-01 challenges
and :func:get_client_dependency for FastAPI dependency injection.
Requires fastapi (install with pip install lacme[fastapi]).
Import from lacme.ext_fastapi (not lacme.fastapi) to avoid
shadowing the fastapi package.
acme_challenge_router ¶
Return a FastAPI APIRouter serving HTTP-01 challenge responses.
Usage::
from lacme.ext_fastapi import acme_challenge_router
app.include_router(acme_challenge_router(handler))
get_client_dependency ¶
Create a FastAPI dependency that returns the lacme Client.
Usage::
from fastapi import Depends
from lacme.ext_fastapi import get_client_dependency
get_client = get_client_dependency(client)
@app.get("/certs/{domain}")
async def get_cert(client: Client = Depends(get_client)):
...
lifespan_issue
async
¶
lifespan_issue(client: Client, domains: str | list[str], *, challenge_type: str = 'http-01') -> None
Issue a certificate during FastAPI lifespan startup.
Usage::
@asynccontextmanager
async def lifespan(app: FastAPI):
await lifespan_issue(client, "example.com")
yield