Skip to main content

ResponseBuilder

Trait ResponseBuilder 

Source
pub trait ResponseBuilder: Send + Sync {
    // Required methods
    fn ok(&self, body: Value) -> HttpResponse;
    fn error(&self, code: StatusCode, message: &str) -> HttpResponse;
    fn streaming(&self, content_type: &str) -> HttpResponse;
    fn with_headers(&self, body: Value, headers: Headers) -> HttpResponse;
    fn redirect(&self, location: &str, permanent: bool) -> HttpResponse;
}
Expand description

Response builder trait for constructing HTTP responses

Required Methods§

Source

fn ok(&self, body: Value) -> HttpResponse

Create a successful response

Source

fn error(&self, code: StatusCode, message: &str) -> HttpResponse

Create an error response

Source

fn streaming(&self, content_type: &str) -> HttpResponse

Create a streaming response

Source

fn with_headers(&self, body: Value, headers: Headers) -> HttpResponse

Create a response with custom headers

Source

fn redirect(&self, location: &str, permanent: bool) -> HttpResponse

Create a redirect response

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§