shio-rs
shio-rs copied to clipboard
Implement something equivalent to request guards
Rocket's request guards are an awesome feature. We should have some equivalent / similar here.
Currently, shio::Context provides a read/write request-local type map. Extend this to allow requests to read (only) from a global type map. Values should be prepared on-demand.
impl shio::request::FromRequest for PgConnection {
// [...]
fn from_request(context: &Context) -> Self::Result { /**/ }
}
fn index(context: Context) -> Result<(), Error> {
let connection = context.get::<PgConnection>()?;
}
- [ ] Decide on final name for
shio::request::FromRequesttraitshio::request::Guard
- [ ] Decide on using
Context::getor finding a new name for this