#Get request from after_request hook

1 messages · Page 1 of 1 (latest)

tribal robin
#

How can I get the request while in an after_request hook? I'm looking to create a unique cookie for each user, but I need to know if there is already a cookie in the request before adding it to the response. An after_request hook seems like the appropriate place, but I was suprised to find that it doesn't pass the request in. Is there a more appropriate place to do this? I guess I can use the server side session middleware, but I don't actually need the session, just the session_id.

tacit quest
patent prismBOT
#

litestar/types/callable_types.py lines 23 to 25

AfterRequestHookHandler: TypeAlias = (
    "Callable[[ASGIApp], SyncOrAsyncUnion[ASGIApp]] | Callable[[Response], SyncOrAsyncUnion[Response]]"
)