pub struct Route {
    pub method: Method,
    pub path: Path,
    pub handler: Handler,
}
Expand description

Holds route information

Fields

method: Method

HTTP method to match

path: Path

Path to match

handler: Handler

Request handler

This should be method that accepts Hyper’s Request and Response:

use hyper::server::{Request, Response};
use hyper::header::{ContentLength, ContentType};

fn hello_handler(_: Request) -> Response {
    let body = "Hello World";
    Response::new()
        .with_header(ContentLength(body.len() as u64))
        .with_header(ContentType::plaintext())
        .with_body(body)
}

Implementations

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

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.