Module builder

Module builder 

Source
Expand description

Laravel-style Response Builder

Provides a fluent builder pattern for creating HTTP responses with intuitive chaining.

§Examples

use elif_http::response::response;
use elif_http::{HttpResult, ElifResponse};

// Clean Laravel-style syntax with terminal methods
async fn list_users() -> HttpResult<ElifResponse> {
    let users = vec!["Alice", "Bob"];
    response().json(users).send()
}

async fn create_user() -> HttpResult<ElifResponse> {
    let user = serde_json::json!({"id": 1, "name": "Alice"});
    response().json(user).created().location("/users/1").send()
}

async fn redirect_user() -> HttpResult<ElifResponse> {
    response().redirect("/login").permanent().send()
}

// Alternative: using .finish() or traditional Ok(.into())
async fn other_examples() -> HttpResult<ElifResponse> {
    // Using finish()
    response().json("data").finish()
     
    // Traditional approach still works
    // Ok(response().json("data").into())
}

Structs§

ResponseBuilder
Response builder for fluent API construction

Functions§

json_response
Global JSON response helper
redirect_response
Global redirect response helper
response
Global response helper function
text_response
Global text response helper