Skip to content

HTTP Parameters in Dependencies

Your dependencies can depend on HTTP parameters. For example, you can get a query parameter from within a dependency. This can be useful to create reusable groups of parameters:

from pydantic import BaseModel

from xpresso import App, FromQuery, Path

class CurrentUser(BaseModel):
    username: FromQuery[str]

async def echo_user(user: CurrentUser) -> CurrentUser:
    return user

app = App(

This applies to parameters as well as request bodies.