Struct rusty_pipe::Router [] [src]

pub struct Router { /* fields omitted */ }

Router provides an interface for creating complex routes as middleware for the Iron framework.

Methods

impl Router
[src]

[src]

Construct a new, empty Router.

let router = Router::new();

[src]

Add a new route to a Router, matching both a method and glob pattern.

route supports glob patterns: * for a single wildcard segment and :param for matching storing that segment of the request url in the Params object, which is stored in the request extensions.

For instance, to route Get requests on any route matching /users/:userid/:friend and store userid and friend in the exposed Params object:

This example is not tested
let mut router = Router::new();
router.route(method::Get, "/users/:userid/:friendid", controller, "user_friend");

route_id is a unique name for your route, and is used when generating an URL with url_for.

The controller provided to route can be any Handler, which allows extreme flexibility when handling routes. For instance, you could provide a Chain, a Handler, which contains an authorization middleware and a controller function, so that you can confirm that the request is authorized for this route before handling it.

[src]

Like route, but specialized to the Get method.

[src]

Like route, but specialized to the Post method.

[src]

Like route, but specialized to the Put method.

[src]

Like route, but specialized to the Delete method.

[src]

Like route, but specialized to the Head method.

[src]

Like route, but specialized to the Patch method.

[src]

Like route, but specialized to the Options method.

[src]

Route will match any method, including gibberish. In case of ambiguity, handlers specific to methods will be preferred.

[src]

Trait Implementations

impl Key for Router
[src]

The value type associated with this key type.

impl Handler for Router
[src]

[src]

Produce a Response from a Request, with the possibility of error.

Auto Trait Implementations

impl Send for Router

impl Sync for Router