Struct canteen::response::Response [] [src]

pub struct Response { /* fields omitted */ }

This struct reprsents the response to an HTTP client.

Methods

impl Response
[src]

[src]

Create a new, empty Response.

[src]

Creates a Response with a JSON body

Examples

Be careful when using this code, it's not being tested!
use canteen::Response;
user serde::Serialize;

#[derive(Serialize)]
struct Foo {
    item: i32,
}

let foo = Foo { item: 12345 };
let res = Response::as_json(&foo);

[src]

Sets the response status for the HTTP response.

Examples

use canteen::Response;

let mut res = Response::new();
res.set_status(200);

[src]

Sets the Content-Type header for the HTTP response.

Examples

use canteen::Response;

let mut res = Response::new();
res.set_content_type("text/html");

[src]

Adds a header to the HTTP response.

Examples

use canteen::Response;

let mut res = Response::new();
res.add_header("Content-Type", "text/html");

[src]

Appends data to the body of the HTTP response. The trait ToOutput must be implemented for the type passed.

Examples

use canteen::Response;

let mut res = Response::new();
let data = "{ message: \"Hello, world!\" }";
res.append(data);

[src]

Returns a byte array containing the full contents of the HTTP response, for use by the Canteen struct.

Trait Implementations

impl Debug for Response
[src]

[src]

Formats the value using the given formatter.