Struct saphir::SyncResponse

source ·
pub struct SyncResponse { /* private fields */ }
Expand description

A Structure which represent a fully mutable http response

Implementations

Set the HTTP status for this response.

This function will configure the HTTP status code of the Response that will be returned from Builder::build.

By default this is 200.

Examples

let response = SyncResponse::new()
    .status(200)
    .build_response()
    .unwrap();

Set the HTTP version for this response.

This function will configure the HTTP version of the Response that will be returned from Builder::build.

By default this is HTTP/1.1

Examples

let response = SyncResponse::new()
    .version(Version::HTTP_2)
    .build_response()
    .unwrap();

Appends a header to this response builder.

This function will append the provided key/value as a header to the internal HeaderMap being constructed. Essentially this is equivalent to calling HeaderMap::append.

Examples

let response = SyncResponse::new()
    .header("Content-Type", "text/html")
    .header("X-Custom-Foo", "bar")
    .build_response()
    .unwrap();

A convinient function to constuct the response headers from a Headers struct

Adds an extension to this builder

Examples

let response = SyncResponse::new()
    .extension("My Extension")
    .build_response()
    .unwrap();

assert_eq!(response.extensions().get::<&'static str>(),
           Some(&"My Extension"));

Adds a body to a response

Examples

let response = SyncResponse::new()
    .body(b"this is a payload")
    .build_response()
    .unwrap();

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.