pub struct ResponseBuilder { /* private fields */ }
Expand description
Response builder for fluent API construction
This struct provides a Laravel-inspired builder pattern for creating HTTP responses. All methods return Self for chaining, and the builder converts to ElifResponse automatically.
Implementations§
Source§impl ResponseBuilder
impl ResponseBuilder
Sourcepub fn no_content(self) -> Self
pub fn no_content(self) -> Self
Set status to 204 No Content
Sourcepub fn bad_request(self) -> Self
pub fn bad_request(self) -> Self
Set status to 400 Bad Request
Set status to 401 Unauthorized
Sourcepub fn unprocessable_entity(self) -> Self
pub fn unprocessable_entity(self) -> Self
Set status to 422 Unprocessable Entity
Sourcepub fn internal_server_error(self) -> Self
pub fn internal_server_error(self) -> Self
Set status to 500 Internal Server Error
Sourcepub fn status(self, status: ElifStatusCode) -> Self
pub fn status(self, status: ElifStatusCode) -> Self
Set custom status code
Sourcepub fn cache_control<S: Into<String>>(self, value: S) -> Self
pub fn cache_control<S: Into<String>>(self, value: S) -> Self
Set cache-control header
Sourcepub fn content_type<S: Into<String>>(self, content_type: S) -> Self
pub fn content_type<S: Into<String>>(self, content_type: S) -> Self
Set content-type header
Add a cookie header (supports multiple cookies)
Sourcepub fn validation_error<T: Serialize>(self, errors: T) -> Self
pub fn validation_error<T: Serialize>(self, errors: T) -> Self
Create validation error response
Sourcepub fn not_found_with_message<S: Into<String>>(self, message: S) -> Self
pub fn not_found_with_message<S: Into<String>>(self, message: S) -> Self
Create not found error with custom message
Sourcepub fn cors_with_credentials(self, origin: &str) -> Self
pub fn cors_with_credentials(self, origin: &str) -> Self
Add CORS headers with credentials
Sourcepub fn with_security_headers(self) -> Self
pub fn with_security_headers(self) -> Self
Add security headers
Sourcepub fn send(self) -> HttpResult<ElifResponse>
pub fn send(self) -> HttpResult<ElifResponse>
Build and return the response wrapped in Ok()
This enables Laravel-style terminal chaining: response().json(data).send() Alternative to: Ok(response().json(data).into())
Sourcepub fn finish(self) -> HttpResult<ElifResponse>
pub fn finish(self) -> HttpResult<ElifResponse>
Build and return the response wrapped in Ok() - alias for send()
This enables Laravel-style terminal chaining: response().json(data).finish()
Sourcepub fn build(self) -> ElifResponse
pub fn build(self) -> ElifResponse
Build the final ElifResponse
Trait Implementations§
Source§impl Debug for ResponseBuilder
impl Debug for ResponseBuilder
Source§impl Default for ResponseBuilder
impl Default for ResponseBuilder
Source§impl From<ResponseBuilder> for ElifResponse
Convert ResponseBuilder to ElifResponse
impl From<ResponseBuilder> for ElifResponse
Convert ResponseBuilder to ElifResponse