Struct canteen::Canteen [] [src]

pub struct Canteen {
    // some fields omitted
}

The primary struct provided by the library. The aim is to have a similar interface to Flask, the Python microframework.

Methods

impl Canteen
[src]

Creates a new Canteen instance.

Examples

let cnt = Canteen::new(("127.0.0.1", 8080));

Adds a new route definition to be handled by Canteen.

Examples

fn handler(_: &Request) -> Response {
    utils::make_response("<b>Hello, world!</b>", "text/html", 200)
}

fn main() {
    let cnt = Canteen::new(("127.0.0.1", 8080));
    cnt.add_route("/hello", &[Request::Get], handler);
}

Defines a default route for undefined paths.

Examples

let cnt = Canteen::new(("127.0.0.1", 8080));
cnt.set_default(canteen::utils::err_404);

Creates the listener and starts a Canteen server's event loop.

Examples

let cnt = Canteen::new(("127.0.0.1", 8080));

Trait Implementations

impl Handler for Canteen
[src]

Invoked when the socket represented by token is ready to be operated on. events indicates the specific operations that are ready to be performed. Read more

Invoked when a message has been received via the event loop's channel.

Invoked when a timeout has completed.

Invoked when EventLoop has been interrupted by a signal interrupt.

Invoked at the end of an event loop tick.