Struct pencil::wrappers::Request [] [src]

pub struct Request<'r, 'a, 'b: 'a> {
    pub app: &'r Pencil,
    pub remote_addr: SocketAddr,
    pub method: Method,
    pub headers: Headers,
    pub url: Url,
    pub url_rule: Option<Rule>,
    pub view_args: ViewArgs,
    pub routing_redirect: Option<(String, u16)>,
    pub routing_error: Option<HTTPError>,
    pub extensions_data: TypeMap,
    // some fields omitted

Request type.


app: &'r Pencil remote_addr: SocketAddr

The IP address of the remote connection.

method: Method

The request method.

headers: Headers

The headers of the incoming request.

url: Url

The requested url.

url_rule: Option<Rule>

The URL rule that matched the request. This is going to be None if nothing matched.

view_args: ViewArgs

A dict of view arguments that matched the request.

routing_redirect: Option<(String, u16)>

If matching the URL requests a redirect, this will be the redirect.

routing_error: Option<HTTPError>

If matching the URL failed, this will be the routing error.

extensions_data: TypeMap

Storage for data of extensions.


impl<'r, 'a, 'b: 'a> Request<'r, 'a, 'b>

fn new(app: &'r Pencil, http_request: HttpRequest<'a, 'b>) -> Result<Request<'r, 'a, 'b>, String>

Create a Request.

fn url_adapter(&self) -> MapAdapter

Get the url adapter for this request.

fn match_request(&mut self)

Match the request, set the url_rule and view_args field.

fn endpoint(&self) -> Option<String>

The endpoint that matched the request.

fn module_name(&self) -> Option<String>

The current module name.

fn args(&mut self) -> &MultiDict<String>

The parsed URL parameters.

fn get_json(&mut self) -> &Option<Json>

Parses the incoming JSON request data.

fn form(&mut self) -> &MultiDict<String>

The form parameters.

fn files(&mut self) -> &MultiDict<FilePart>

All uploaded files.

fn headers(&self) -> &Headers

The headers.

fn path(&self) -> String

Requested path.

fn full_path(&self) -> String

Requested path including the query string.

fn host(&self) -> String

The host including the port if available.

fn query_string(&self) -> Option<String>

The query string.

fn cookies(&self) -> Option<&Cookie>

The retrieved cookies.

fn method(&self) -> Method

The request method.

fn remote_addr(&self) -> SocketAddr

The remote address of the client.

fn scheme(&self) -> String

URL scheme (http or https)

fn host_url(&self) -> String

Just the host with scheme.

fn url(&self) -> String

The current url.

fn base_url(&self) -> String

The current url without the query string.

fn is_secure(&self) -> bool

Whether the request is secure (https).

Trait Implementations

impl<'r, 'a, 'b: 'a> Debug for Request<'r, 'a, 'b>

fn fmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<'r, 'a, 'b: 'a> Read for Request<'r, 'a, 'b>

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usizeError>

Read all bytes until EOF in this source, placing them into buf. Read more

fn read_to_string(&mut self, buf: &mut String) -> Result<usizeError>

Read all bytes until EOF in this source, placing them into buf. Read more

fn read_exact(&mut self, buf: &mut [u8]) -> Result<()Error>

Read the exact number of bytes required to fill buf. Read more

fn by_ref(&mut self) -> &mut Self

Creates a "by reference" adaptor for this instance of Read. Read more

fn bytes(self) -> Bytes<Self>

Transforms this Read instance to an Iterator over its bytes. Read more

fn chars(self) -> Chars<Self>

Unstable (io)

: the semantics of a partial read/write of where errors happen is currently unclear and may change

Transforms this Read instance to an Iterator over chars. Read more

fn chain<R>(self, next: R) -> Chain<Self, R> where R: Read

Creates an adaptor which will chain this stream with another. Read more

fn take(self, limit: u64) -> Take<Self>

Creates an adaptor which will read at most limit bytes from it. Read more