Trait sputnik::request::SputnikParts
source · [−]pub trait SputnikParts {
fn query<'a, X: Deserialize<'a>>(&'a self) -> Result<X, QueryError>;
fn cookies(&self) -> CookieIter<'_>ⓘNotable traits for CookieIter<'a>impl<'a> Iterator for CookieIter<'a> type Item = (&'a str, &'a str);
;
fn enforce_content_type(
&self,
mime: Mime
) -> Result<(), WrongContentTypeError>;
fn response_headers(&mut self) -> &mut HeaderMap;
}
Expand description
Adds convenience methods to http::request::Parts
.
Required Methods
fn query<'a, X: Deserialize<'a>>(&'a self) -> Result<X, QueryError>
fn query<'a, X: Deserialize<'a>>(&'a self) -> Result<X, QueryError>
Parses the query string of the request into a given struct.
Parses the cookies of the request.
fn enforce_content_type(&self, mime: Mime) -> Result<(), WrongContentTypeError>
fn enforce_content_type(&self, mime: Mime) -> Result<(), WrongContentTypeError>
Enforces a specific Content-Type.
fn response_headers(&mut self) -> &mut HeaderMap
fn response_headers(&mut self) -> &mut HeaderMap
A map of response headers to allow methods of this trait to set response
headers without needing to take a Response
as an argument.
You need to take care to append these headers to the response yourself. This is intended to be done after your routing logic so that your individual request handlers don’t have to worry about it.