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§
Sourcefn ok(&self, body: Value) -> HttpResponse
fn ok(&self, body: Value) -> HttpResponse
Create a successful response
Sourcefn error(&self, code: StatusCode, message: &str) -> HttpResponse
fn error(&self, code: StatusCode, message: &str) -> HttpResponse
Create an error response
Sourcefn streaming(&self, content_type: &str) -> HttpResponse
fn streaming(&self, content_type: &str) -> HttpResponse
Create a streaming response
Sourcefn with_headers(&self, body: Value, headers: Headers) -> HttpResponse
fn with_headers(&self, body: Value, headers: Headers) -> HttpResponse
Create a response with custom headers
Sourcefn redirect(&self, location: &str, permanent: bool) -> HttpResponse
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".