pub struct ProtoContext<T> {
pub body: Option<ProtoBody>,
pub query_params: Option<HashMap<String, String>>,
pub status: u16,
pub hyper_request: Option<HyperRequest>,
pub extra: T,
/* private fields */
}Fields§
§body: Option<ProtoBody>§query_params: Option<HashMap<String, String>>§status: u16§hyper_request: Option<HyperRequest>§extra: TImplementations§
Source§impl<T> ProtoContext<T>
impl<T> ProtoContext<T>
pub fn new(req: HyperRequest, extra: T) -> ProtoContext<T>
Sourcepub fn content_type(&mut self, c_type: &str)
pub fn content_type(&mut self, c_type: &str)
Set the response Content-Type. A shortcode for
ⓘ
ctx.set("Content-Type", "some-val");Sourcepub fn redirect(&mut self, destination: &str)
pub fn redirect(&mut self, destination: &str)
Set up a redirect, will default to 302, but can be changed after the fact.
ⓘ
ctx.set("Location", "/some-path");
ctx.status(302);Sets a cookie on the response
pub fn set_http2(&mut self)
pub fn set_http11(&mut self)
pub fn set_http10(&mut self)
pub fn set_proto_status(&mut self, status: u16)
Trait Implementations§
Source§impl<T> Clone for ProtoContext<T>
impl<T> Clone for ProtoContext<T>
Source§impl<T> Context for ProtoContext<T>
impl<T> Context for ProtoContext<T>
type Response = Response<ProtoBody>
Source§fn get_response(self) -> Self::Response
fn get_response(self) -> Self::Response
get_response returns a fully created response object based on the contents
of the Context. This means setting the body according to whatever has been
stored via set_body and/or set_body_bytes, as well as adding the proper
headers that have been added via the set method.
Source§fn set_body(&mut self, body: Vec<u8>)
fn set_body(&mut self, body: Vec<u8>)
set_body is used to set the body using a vec of bytes on the context. The
contents will be used later for generating the correct response.
Source§fn set_body_bytes(&mut self, bytes: Bytes)
fn set_body_bytes(&mut self, bytes: Bytes)
set_body_byte is used to set the body using a Bytes object on the context.
The contents will be used later for generating the correct response.
Source§fn route(&self) -> &str
fn route(&self) -> &str
route is used to return the route from the incoming request as a string.
Source§impl<T: Default> Default for ProtoContext<T>
impl<T: Default> Default for ProtoContext<T>
Source§fn default() -> ProtoContext<T>
fn default() -> ProtoContext<T>
Returns the “default value” for a type. Read more
Source§impl<T> HasQueryParams for ProtoContext<T>
impl<T> HasQueryParams for ProtoContext<T>
Source§impl<T: Send> ProtoContextExt<T> for ProtoContext<T>
impl<T: Send> ProtoContextExt<T> for ProtoContext<T>
Auto Trait Implementations§
impl<T> !Freeze for ProtoContext<T>
impl<T> !RefUnwindSafe for ProtoContext<T>
impl<T> Send for ProtoContext<T>where
T: Send,
impl<T> Sync for ProtoContext<T>where
T: Sync,
impl<T> Unpin for ProtoContext<T>where
T: Unpin,
impl<T> !UnwindSafe for ProtoContext<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more