Skip to content

POST Request route #1234

@andodeki

Description

@andodeki

I am have this endpoint a post request which does not respond even the the print statement i have in the function
It this even the way a post request fn is created

async fn create_user(
    StateRef(state): StateRef<'_, AppState>,
    ExtensionRef(user_data): ExtensionRef<'_, CreateUserRequest>,
) -> String {
    println!("Testing Create User API");
    let id = state
        .user_db
        .next_id
        .fetch_add(1, std::sync::atomic::Ordering::SeqCst)
        .to_string();
    let _new_user = User {
        id,
        name: user_data.name.clone(),
        email: user_data.email.clone(),
        created_at: chrono::Local::now().to_rfc3339(),
    };   
}

below is the routes of said request

let app = App::new()
        .with_state(state)
        .at("/test-post", post(handler_service(async || "POST works\n")))
        .at("/users/create", post(handler_service(create_user)));

the test-post works though

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions