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

pub struct MethodRouter<T> { /* fields omitted */ }

A router that selects a handler from an HTTP method.

It's a simple mapping between Method and a router T, while the requested path is ignored. It's therefore a good idea to pair a MethodRouter with an exhaustive path router of some sort.

Methods

impl<T> MethodRouter<T>
[src]

Create an empty MethodRouter.

Build the router and its children using a chaninable API.

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 that will listen for a specific status code.

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

let route_tree = TreeRouter::<Option<fn(Context, Response)>>::new();
//Fill route_tree with handlers...

let mut method_router = MethodRouter::new();
method_router.insert(Method::Get, route_tree);

Trait Implementations

impl<T: Clone> Clone for MethodRouter<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: HandleRequest> HandleRequest for MethodRouter<T>
[src]

Try to handle an incoming request from the client, or return the request environment to the parent handler. Read more

List all of the hyperlinks into this handler, based on the provided base link. It's up to the handler implementation to decide how deep to go. Read more

impl<T> Default for MethodRouter<T>
[src]

Returns the "default value" for a type. Read more

impl<'a, T: 'a> Build<'a> for MethodRouter<T>
[src]

The type that provides the builder API.

Get the builder type for this type, and prepare it with a context.

impl<T: ApplyContext> ApplyContext for MethodRouter<T>
[src]

Set properties, based on a given context.

Prepend existing properties, based on a given context.

impl<T: Merge> Merge for MethodRouter<T>
[src]

Combine this handler with another, overwriting conflicting properties.

Auto Trait Implementations

impl<T> Send for MethodRouter<T> where
    T: Send

impl<T> Sync for MethodRouter<T> where
    T: Sync