shio-rs icon indicating copy to clipboard operation
shio-rs copied to clipboard

Implement something equivalent to request guards

Open mehcode opened this issue 8 years ago • 0 comments

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::FromRequest trait
    • shio::request::Guard
  • [ ] Decide on using Context::get or finding a new name for this

mehcode avatar Aug 30 '17 05:08 mehcode