pub struct ElifResponse { /* private fields */ }Expand description
Response builder for creating HTTP responses with fluent API
Implementations§
Source§impl ElifResponse
impl ElifResponse
Sourcepub fn with_status(status: StatusCode) -> Self
pub fn with_status(status: StatusCode) -> Self
Create response with specific status code
Sourcepub fn status(self, status: StatusCode) -> Self
pub fn status(self, status: StatusCode) -> Self
Set response status code
Sourcepub fn header<K, V>(self, key: K, value: V) -> HttpResult<Self>
pub fn header<K, V>(self, key: K, value: V) -> HttpResult<Self>
Add header to response
Sourcepub fn content_type(self, content_type: &str) -> HttpResult<Self>
pub fn content_type(self, content_type: &str) -> HttpResult<Self>
Set Content-Type header
Sourcepub fn json<T: Serialize>(self, data: &T) -> HttpResult<Self>
pub fn json<T: Serialize>(self, data: &T) -> HttpResult<Self>
Set response body as JSON
Sourcepub fn json_value(self, value: Value) -> Self
pub fn json_value(self, value: Value) -> Self
Set response body as raw JSON value
Sourcepub fn build(self) -> HttpResult<Response<Body>>
pub fn build(self) -> HttpResult<Response<Body>>
Build the response
Source§impl ElifResponse
Convenience methods for common response types
impl ElifResponse
Convenience methods for common response types
Sourcepub fn no_content() -> Self
pub fn no_content() -> Self
Create 204 No Content response
Sourcepub fn bad_request() -> Self
pub fn bad_request() -> Self
Create 400 Bad Request response
Create 401 Unauthorized response
Sourcepub fn unprocessable_entity() -> Self
pub fn unprocessable_entity() -> Self
Create 422 Unprocessable Entity response
Sourcepub fn internal_server_error() -> Self
pub fn internal_server_error() -> Self
Create 500 Internal Server Error response
Sourcepub fn json_ok<T: Serialize>(data: &T) -> HttpResult<Response<Body>>
pub fn json_ok<T: Serialize>(data: &T) -> HttpResult<Response<Body>>
Create JSON response with data
Sourcepub fn json_error(
status: StatusCode,
message: &str,
) -> HttpResult<Response<Body>>
pub fn json_error( status: StatusCode, message: &str, ) -> HttpResult<Response<Body>>
Create JSON error response
Sourcepub fn validation_error<T: Serialize>(errors: &T) -> HttpResult<Response<Body>>
pub fn validation_error<T: Serialize>(errors: &T) -> HttpResult<Response<Body>>
Create validation error response
Source§impl ElifResponse
Redirect response builders
impl ElifResponse
Redirect response builders
Sourcepub fn redirect_permanent(location: &str) -> HttpResult<Self>
pub fn redirect_permanent(location: &str) -> HttpResult<Self>
Create 301 Moved Permanently redirect
Sourcepub fn redirect_temporary(location: &str) -> HttpResult<Self>
pub fn redirect_temporary(location: &str) -> HttpResult<Self>
Create 302 Found (temporary) redirect
Sourcepub fn redirect_see_other(location: &str) -> HttpResult<Self>
pub fn redirect_see_other(location: &str) -> HttpResult<Self>
Create 303 See Other redirect
Source§impl ElifResponse
File download response builders
impl ElifResponse
File download response builders
Sourcepub fn download(filename: &str, content: Bytes) -> HttpResult<Self>
pub fn download(filename: &str, content: Bytes) -> HttpResult<Self>
Create file download response
Sourcepub fn file_inline(
filename: &str,
content_type: &str,
content: Bytes,
) -> HttpResult<Self>
pub fn file_inline( filename: &str, content_type: &str, content: Bytes, ) -> HttpResult<Self>
Create inline file response (display in browser)
Trait Implementations§
Source§impl Debug for ElifResponse
impl Debug for ElifResponse
Source§impl Default for ElifResponse
impl Default for ElifResponse
Source§impl IntoResponse for ElifResponse
Convert ElifResponse to Axum Response
impl IntoResponse for ElifResponse
Convert ElifResponse to Axum Response
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Auto Trait Implementations§
impl !Freeze for ElifResponse
impl RefUnwindSafe for ElifResponse
impl Send for ElifResponse
impl Sync for ElifResponse
impl Unpin for ElifResponse
impl UnwindSafe for ElifResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more