Struct nickel::Request

source ·
pub struct Request<'mw, 'server: 'mw, D: 'mw = ()> {
    pub origin: HyperRequest<'mw, 'server>,
    pub route_result: Option<RouteResult<'mw, D>>,
    /* private fields */
}
Expand description

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

Implementations

Trait Implementations

Get a reference to the type’s extension storage.
Get a mutable reference to the type’s extension storage.
Extracts URL encoded data from the request body. Read more
Return a copy of the plugin’s produced value. Read more
Return a reference to the plugin’s produced value. Read more
Return a mutable reference to the plugin’s produced value. Read more
Create and evaluate a once-off instance of a plugin.
Extracts URL encoded data from the URL query string. Read more

Get the Request’s referer header

Examples
extern crate nickel;

use nickel::{Nickel, HttpRouter, Request, Response, MiddlewareResult};
use nickel::extensions::{Referer, Redirect};

fn referer<'mw, 'conn>(req: &mut Request<'mw, 'conn>, res: Response<'mw>) -> MiddlewareResult<'mw> {
    let back = req.referer().unwrap_or("http://nickel-org.github.io/");
    return res.redirect(back)
}

fn main() {
    let mut server = Nickel::new();
    server.get("/a", referer);
}

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Get the TypeId of this object.