Struct NickelRequest

Source
pub struct NickelRequest<'mw, 'server, D = ()>
where 'server: 'mw, D: 'mw,
{ pub origin: Request<'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: Request<'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§

Source§

impl<'mw, 'server, D> Request<'mw, 'server, D>

Source

pub fn from_internal( req: Request<'mw, 'server>, data: &'mw D, ) -> Request<'mw, 'server, D>

Source

pub fn param(&self, key: &str) -> Option<&str>

Source

pub fn path_without_query(&self) -> Option<&str>

Source

pub fn server_data(&self) -> &'mw D

Trait Implementations§

Source§

impl<'r, 'mw: 'r, 'server: 'mw, D: 'mw> AsMut<&'r mut Request<'mw, 'server, D>> for Maybe<'r, 'mw, 'server, D>

Source§

fn as_mut(&mut self) -> &mut &'r mut NickelRequest<'mw, 'server, D>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<'r, 'mw: 'r, 'server: 'mw, D: 'mw> AsRef<&'r mut Request<'mw, 'server, D>> for Maybe<'r, 'mw, 'server, D>

Source§

fn as_ref(&self) -> &&'r mut NickelRequest<'mw, 'server, D>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'mw, 'server, D> Extensible for Request<'mw, 'server, D>

Source§

fn extensions(&self) -> &TypeMap

Get a reference to the type’s extension storage.
Source§

fn extensions_mut(&mut self) -> &mut TypeMap

Get a mutable reference to the type’s extension storage.
Source§

impl<'mw, 'conn, D> FormBody for Request<'mw, 'conn, D>

Source§

fn form_body(&mut self) -> Result<&Params, (StatusCode, BodyError)>

Extracts URL encoded data from the request body. Read more
Source§

impl<'r, 'mw: 'r, 'server: 'mw, D: 'mw> From<&'r mut Request<'mw, 'server, D>> for Maybe<'r, 'mw, 'server, D>

Source§

fn from(req: &'r mut NickelRequest<'mw, 'server, D>) -> Self

Converts to this type from the input type.
Source§

impl<'r, 'mw: 'r, 'server: 'mw, D: 'mw> Into<&'r mut Request<'mw, 'server, D>> for Maybe<'r, 'mw, 'server, D>

Source§

fn into(self) -> &'r mut NickelRequest<'mw, 'server, D>

Converts this type into the (usually inferred) input type.
Source§

impl<'mw, 'conn, D> JsonBody for Request<'mw, 'conn, D>

Source§

fn json_as<'a, T>(&'a mut self) -> Result<T, Error>
where T: Deserialize<'a>,

Source§

impl<'mw, 'server, D: 'mw> MultipartBody<'mw, 'server> for NickelRequest<'mw, 'server, D>

Source§

fn multipart_body( &mut self, ) -> Option<Multipart<&mut HyperRequest<'mw, 'server>>>

Get a multipart reader for the request body, if the request is of the right type.
Source§

impl<'mw, 'server, D> Pluggable for Request<'mw, 'server, D>

Source§

fn get<P>(&mut self) -> Result<<P as Key>::Value, <P as Plugin<Self>>::Error>
where P: Plugin<Self>, <P as Key>::Value: Clone + Any, Self: Extensible,

Return a copy of the plugin’s produced value. Read more
Source§

fn get_ref<P>( &mut self, ) -> Result<&<P as Key>::Value, <P as Plugin<Self>>::Error>
where P: Plugin<Self>, <P as Key>::Value: Any, Self: Extensible,

Return a reference to the plugin’s produced value. Read more
Source§

fn get_mut<P>( &mut self, ) -> Result<&mut <P as Key>::Value, <P as Plugin<Self>>::Error>
where P: Plugin<Self>, <P as Key>::Value: Any, Self: Extensible,

Return a mutable reference to the plugin’s produced value. Read more
Source§

fn compute<P>( &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.
Source§

impl<'mw, 'conn, D> QueryString for Request<'mw, 'conn, D>

Source§

fn query(&mut self) -> &Params

Extracts URL encoded data from the URL query string. Read more
Source§

impl<'mw, 'server, D> Referer for Request<'mw, 'server, D>

Source§

fn referer(&self) -> Option<&str>

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§

§

impl<'mw, 'server, D> Freeze for Request<'mw, 'server, D>

§

impl<'mw, 'server, D = ()> !RefUnwindSafe for Request<'mw, 'server, D>

§

impl<'mw, 'server, D = ()> !Send for Request<'mw, 'server, D>

§

impl<'mw, 'server, D = ()> !Sync for Request<'mw, 'server, D>

§

impl<'mw, 'server, D> Unpin for Request<'mw, 'server, D>

§

impl<'mw, 'server, D = ()> !UnwindSafe for Request<'mw, 'server, D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Typeable for T
where T: Any,

Source§

fn get_type(&self) -> TypeId

Get the TypeId of this object.
Source§

impl<T> UnsafeAny for T
where T: Any,