Skip to content

cattle_grid.tools.fastapi

ActivityPubHeaders module-attribute

ActivityPubHeaders = Annotated[APHeaders, Header()]

Annotation to evaluate the APHeaders

ShouldServe module-attribute

ShouldServe = Annotated[
    list[ContentType], Depends(should_server_from_accept)
]

Determines the list of ContentType one should serve

APHeaders

Bases: BaseModel

Headers every request should have. These should be added by the remote proxy.

Parameters:

Name Type Description Default
x_cattle_grid_requester str | None

URI of the actor making the request

None
x_cattle_grid_should_serve str | None

Type of content cattle_grid should serve

None
x_ap_location str

URI of the resource being retrieved

required
Source code in cattle_grid/tools/fastapi/__init__.py
class APHeaders(BaseModel):
    """Headers every request should have. These should be added by the remote proxy."""

    x_cattle_grid_requester: str | None = Field(
        default=None, description="URI of the actor making the request"
    )
    x_cattle_grid_should_serve: str | None = Field(
        default=None, description="Type of content cattle_grid should serve"
    )
    x_ap_location: str = Field(description="URI of the resource being retrieved")

ActivityResponse

Bases: JSONResponse

Response that ensures the content-type is “application/activity+json”

Source code in cattle_grid/tools/fastapi/__init__.py
class ActivityResponse(JSONResponse):
    """Response that ensures the content-type is
    "application/activity+json"
    """

    media_type = "application/activity+json"

ContentType

Bases: StrEnum

The content type of the response

Source code in cattle_grid/tools/fastapi/http_util.py
class ContentType(StrEnum):
    """The content type of the response"""

    activity_pub = auto()
    html = auto()
    other = auto()

JrdResponse

Bases: JSONResponse

Response that ensures the content-type is “application/jrd+json”

Source code in cattle_grid/tools/fastapi/__init__.py
class JrdResponse(JSONResponse):
    """Response that ensures the content-type is
    "application/jrd+json"
    """

    media_type = "application/jrd+json"