Trait gotham::handler::IntoResponse [] [src]

pub trait IntoResponse {
    fn into_response(self, state: &State) -> Response;
}

Represents a type which can be converted to a response. This trait is used in converting the return type of a function into a response.

Examples

struct MyStruct {
    value: String
}

impl MyStruct {
    fn new() -> MyStruct {
        // ...
    }
}

impl IntoResponse for MyStruct {
    fn into_response(self, _state: &State) -> Response {
        Response::new()
            .with_status(StatusCode::Ok)
            .with_body(self.value)
    }
}

fn handler(state: State) -> (State, MyStruct) {
    (state, MyStruct::new())
}

    tree_builder.add_route(Box::new(route));
    let tree = tree_builder.finalize();
    Router::new(tree, finalizer);

Required Methods

Converts this value into a hyper::Response

Implementations on Foreign Types

impl IntoResponse for Response
[src]

[src]

impl<T, E> IntoResponse for Result<T, E> where
    T: IntoResponse,
    E: IntoResponse
[src]

[src]

Implementors