This changes how sessions are provided by the middleware in order to
support the ability to use session methods, like regenerate. Crucially
sessions are no longer cloned and instead are stored via a handle. This
handle is defined as Arc<RwLock<async_session::Session>> which allows
us to clone the Arc without cloning the contained session directly.
In order to support better ergonomics we also introduce two new
extractors: ReadableSession and WritableSession. These respectively
enable reading and writing of sessions. Internally they acquire the lock
and expose the session for manipulation.
One downside to this approach is that library consumers now need to use
two separate types as opposed to using async_session::Session via
Extension directly. However the API here now no longer requires
Extension and enforces explicit usage of reading and writing via the
public type interface.
This changes how sessions are provided by the middleware in order to support the ability to use session methods, like
regenerate
. Crucially sessions are no longer cloned and instead are stored via a handle. This handle is defined asArc<RwLock<async_session::Session>>
which allows us to clone theArc
without cloning the contained session directly.In order to support better ergonomics we also introduce two new extractors:
ReadableSession
andWritableSession
. These respectively enable reading and writing of sessions. Internally they acquire the lock and expose the session for manipulation.One downside to this approach is that library consumers now need to use two separate types as opposed to using
async_session::Session
viaExtension
directly. However the API here now no longer requiresExtension
and enforces explicit usage of reading and writing via the public type interface.Fixes: #5.