[][src]Struct wascc_codec::http::Response

pub struct Response {
    pub status_code: u32,
    pub status: String,
    pub header: HashMap<String, String>,
    pub body: Vec<u8>,
}

Represents an HTTP response

Fields

status_code: u32

The response's numerical status code (e.g. 200)

status: String

The string version of the status (e.g. 'OK')

header: HashMap<String, String>

HTTP response headers as key-value pairs.

body: Vec<u8>

The raw bytes of the body

Implementations

impl Response[src]

pub fn json<T>(payload: T, status_code: u32, status: &str) -> Response where
    T: Serialize
[src]

Creates a response with a given status code and serializes the given payload as JSON

pub fn not_found() -> Response[src]

Handy shortcut for creating a 404/Not Found response

pub fn ok() -> Response[src]

Useful shortcut for creating a 200/OK response

pub fn internal_server_error(msg: &str) -> Response[src]

Useful shortcut for creating a 500/Internal Server Error response

pub fn bad_request() -> Response[src]

Shortcut for creating a 400/Bad Request response

Trait Implementations

impl Debug for Response[src]

impl Default for Response[src]

impl<'de> Deserialize<'de> for Response[src]

impl PartialEq<Response> for Response[src]

impl Sample for Response[src]

impl Serialize for Response[src]

impl StructuralPartialEq for Response[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.