Closed ppena-LiveData closed 4 months ago
Your middleware approach is a valid solution. You don't need a custom store since you can get session from scope['session']
and then you can modify session contents as you wish.
Anyway, I don't want HTTP context to leak into sessions as the only thing that connects session store and HTTP request is cookie name.
Our custom
starsessions.SessionStore
has different processing depending on the status code of the response, but there's no easy way for us to get that status code. To workaround that, we had to create astarlette
middleware just to inject the status code. Ifstarsessions.SessionStore.write
was passed thestarlette.types.Message
, then the store would be able to get themessage['status']
directly without us needing a separate middleware class to get it.Here's a simplified example of what we currently have to do: