[][src]Module iron::modifiers

This module defines a series of convenience modifiers for changing Responses.

Modifiers can be used to edit Responses through the owning method set or the mutating set_mut, both of which are defined in the Set trait.

For Iron, the Modifier interface offers extensible and ergonomic response creation while avoiding the introduction of many highly specific Response constructors.

The simplest case of a modifier is probably the one used to change the return status code:

let r = Response::with(status::NotFound);
assert_eq!(r.status.unwrap().to_u16(), 404);

You can also pass in a tuple of modifiers, they will all be applied. Here's an example of a modifier 2-tuple that will change the status code and the body message:

Response::with((status::ImATeapot, "I am a tea pot!"));

There is also a Redirect modifier:

let url = Url::parse("http://doc.rust-lang.org").unwrap();
Response::with((status::Found, modifiers::Redirect(url)));

The modifiers are applied depending on their type. Currently the easiest way to see how different types are used as modifiers, take a look at the source code.

For more information about the modifier system, see rust-modifier.

Structs

Header

A modifier for changing headers on requests and responses.

Redirect

A modifier for creating redirect responses.

RedirectRaw

A modifier for creating redirect responses.