Trait thruster::context::context_ext::ContextExt
source · pub trait ContextExt {
// Required methods
fn params<'a>(&'a self) -> &'a Params;
fn json<T: Serialize>(&mut self, body: &T) -> Result<(), Box<dyn Error>>;
fn get_json<'life0, 'async_trait, T>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<T, Box<dyn Error>>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned,
Self: 'async_trait,
'life0: 'async_trait;
fn req_header<'a>(&'a self, header: &str) -> Option<&'a str>;
}
Required Methods§
sourcefn json<T: Serialize>(&mut self, body: &T) -> Result<(), Box<dyn Error>>
fn json<T: Serialize>(&mut self, body: &T) -> Result<(), Box<dyn Error>>
Set the response as JSON.
This method both sets the Content-Type header as well as the body as JSON.
sourcefn get_json<'life0, 'async_trait, T>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<T, Box<dyn Error>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned,
Self: 'async_trait,
'life0: 'async_trait,
fn get_json<'life0, 'async_trait, T>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<T, Box<dyn Error>>> + Send + 'async_trait>>where T: 'async_trait + DeserializeOwned, Self: 'async_trait, 'life0: 'async_trait,
Gets the request body as JSON.
sourcefn req_header<'a>(&'a self, header: &str) -> Option<&'a str>
fn req_header<'a>(&'a self, header: &str) -> Option<&'a str>
Retrieves a header from the incoming request object.