Struct nickel::Request
[−]
[src]
pub struct Request<'mw, 'server: 'mw, D: 'mw = ()> { pub origin: HyperRequest<'mw, 'server>, pub route_result: Option<RouteResult<'mw, D>>, // some fields omitted }
A container for all the request data.
The lifetime 'mw
represents the lifetime of various bits of
middleware state within nickel. It can vary and get shorter.
The lifetime 'server
represents the lifetime of data internal to
the server. It is fixed and longer than 'mw
.
Fields
origin: HyperRequest<'mw, 'server>
the original hyper::server::Request
route_result: Option<RouteResult<'mw, D>>
a HashMap<String, String>
holding all params with names and values
Methods
impl<'mw, 'server, D> Request<'mw, 'server, D>
[src]
fn from_internal(
req: HyperRequest<'mw, 'server>,
data: &'mw D
) -> Request<'mw, 'server, D>
req: HyperRequest<'mw, 'server>,
data: &'mw D
) -> Request<'mw, 'server, D>
fn param(&self, key: &str) -> Option<&str>
fn path_without_query(&self) -> Option<&str>
fn server_data(&self) -> &'mw D
Trait Implementations
impl<'mw, 'server, D> Extensible for Request<'mw, 'server, D>
[src]
fn extensions(&self) -> &TypeMap
Get a reference to the type's extension storage.
fn extensions_mut(&mut self) -> &mut TypeMap
Get a mutable reference to the type's extension storage.
impl<'mw, 'server, D> Pluggable for Request<'mw, 'server, D>
[src]
fn get<P>(&mut self) -> Result<<P as Key>::Value, <P as Plugin<Self>>::Error> where
P: Plugin<Self>,
Self: Extensible,
<P as Key>::Value: Clone,
<P as Key>::Value: Any,
P: Plugin<Self>,
Self: Extensible,
<P as Key>::Value: Clone,
<P as Key>::Value: Any,
Return a copy of the plugin's produced value. Read more
fn get_ref<P>(
&mut self
) -> Result<&<P as Key>::Value, <P as Plugin<Self>>::Error> where
P: Plugin<Self>,
Self: Extensible,
<P as Key>::Value: Any,
&mut self
) -> Result<&<P as Key>::Value, <P as Plugin<Self>>::Error> where
P: Plugin<Self>,
Self: Extensible,
<P as Key>::Value: Any,
Return a reference to the plugin's produced value. Read more
fn get_mut<P>(
&mut self
) -> Result<&mut <P as Key>::Value, <P as Plugin<Self>>::Error> where
P: Plugin<Self>,
Self: Extensible,
<P as Key>::Value: Any,
&mut self
) -> Result<&mut <P as Key>::Value, <P as Plugin<Self>>::Error> where
P: Plugin<Self>,
Self: Extensible,
<P as Key>::Value: Any,
Return a mutable reference to the plugin's produced value. Read more
fn compute<P>(
&mut self
) -> Result<<P as Key>::Value, <P as Plugin<Self>>::Error> where
P: Plugin<Self>,
&mut self
) -> Result<<P as Key>::Value, <P as Plugin<Self>>::Error> where
P: Plugin<Self>,
Create and evaluate a once-off instance of a plugin.
impl<'mw, 'conn, D> FormBody for Request<'mw, 'conn, D>
[src]
fn form_body(&mut self) -> Result<&Params, (StatusCode, BodyError)>
Extracts URL encoded data from the request body. # Examples ```{rust} #[macro_use] extern crate nickel; use nickel::{Nickel, HttpRouter, FormBody}; Read more
impl<'mw, 'conn, D> JsonBody for Request<'mw, 'conn, D>
[src]
impl<'mw, 'conn, D> QueryString for Request<'mw, 'conn, D>
[src]
fn query(&mut self) -> &Query
Extracts URL encoded data from the URL query string. # Examples ```{rust} #[macro_use] extern crate nickel; use nickel::{Nickel, HttpRouter, QueryString}; Read more
impl<'mw, 'server, D> Referer for Request<'mw, 'server, D>
[src]
fn referer(&self) -> Option<&str>
Get the Request's referer header
Examples
#[macro_use] extern crate nickel; use nickel::{Nickel, HttpRouter}; use nickel::extensions::{Referer, Redirect}; fn main() { let mut server = Nickel::new(); server.get("/a", middleware! { |req, res| let back = req.referer().unwrap_or("http://nickel.rs"); return res.redirect(back) }); }