Struct rustful::handler::method_router::Builder [] [src]

pub struct Builder<'a, T: 'a> { /* fields omitted */ }

A builder for a MethodRouter.

Methods

impl<'a, T> Builder<'a, T>
[src]

Perform more than one operation on this builder.

use rustful::{Context, Response};
use rustful::handler::MethodRouter;

fn get(_context: Context, response: Response) {
    response.send("A GET request.");
}

fn post(_context: Context, response: Response) {
    response.send("A POST request.");
}

let mut method_router = MethodRouter::<fn(Context, Response)>::new();

method_router.build().many(|mut method_router|{
    method_router.on_get(get as fn(Context, Response));
    method_router.on_post(post);
});

Insert a handler for GET requests.

use rustful::{Context, Response};
use rustful::handler::MethodRouter;

fn handler(_context: Context, response: Response) {
    response.send("Hello world!");
}

let mut method_router = MethodRouter::<fn(Context, Response)>::new();

method_router.build().on_get(handler as fn(Context, Response));

Insert a handler for POST requests. See on_get for an example.

Insert a handler for PATCH requests. See on_get for an example.

Insert a handler for PUT requests. See on_get for an example.

Insert a handler for DELETE requests. See on_get for an example.

Insert a handler for OPTION requests. See on_get for an example.

Insert a handler for HEAD requests. See on_get for an example.

Insert a handler for CONNECT requests. See on_get for an example.

Insert a handler, similar to on_get, but for any HTTP method.

use rustful::{Context, Response};
use rustful::handler::MethodRouter;

fn handler(_context: Context, response: Response) {
    response.send("Hello world!");
}

let mut method_router = MethodRouter::<fn(Context, Response)>::new();

method_router.build().on(choose_a_method(), handler as fn(Context, Response));

impl<'a: 'b, 'b, T: Default + ApplyContext + Build<'b>> Builder<'a, T>
[src]

Build a handler and its children, for GET requests.

use rustful::{Context, Response};
use rustful::handler::{MethodRouter, TreeRouter};

fn handler(_context: Context, response: Response) {
    response.send("Hello world!");
}

let mut method_router = MethodRouter::<TreeRouter<Option<fn(Context, Response)>>>::new();

method_router.build().get().on_path("hello/world", handler as fn(Context, Response));

Build a handler and its children, for POST requests. See get for an example.

Build a handler and its children, for PATCH requests. See get for an example.

Build a handler and its children, for PUT requests. See get for an example.

Build a handler and its children, for DELETE requests. See get for an example.

Build a handler and its children, for OPTIONS requests. See get for an example.

Build a handler and its children, for HEAD requests. See get for an example.

Build a handler and its children, for CONNECT requests. See get for an example.

Build a handler and its children, similar to get, but for any HTTP method.

use rustful::{Context, Response};
use rustful::handler::{MethodRouter, TreeRouter};

fn handler(_context: Context, response: Response) {
    response.send("Hello world!");
}

let mut method_router = MethodRouter::<TreeRouter<Option<fn(Context, Response)>>>::new();

method_router.build()
    .method(choose_a_method())
    .on_path("hello/world", handler as fn(Context, Response));

impl<'a, T: Merge + ApplyContext> Builder<'a, T>
[src]

Move handlers from another router into this, overwriting conflicting handlers and properties.

Trait Implementations

Auto Trait Implementations

impl<'a, T> !Send for Builder<'a, T>

impl<'a, T> !Sync for Builder<'a, T>