Skip to content

[4.2] User API handlers: list_users, create_user, get_user #3

@lomartins

Description

@lomartins

Phase 4.2 — User API handlers (Medium)

Fill in the handler bodies in backend/src/api/mod.rs. Claude provides the function signatures.

Handlers to implement

// GET /api/v1/users
async fn list_users(State(pool): State<PgPool>) -> impl IntoResponse

// POST /api/v1/users
async fn create_user(
    State(pool): State<PgPool>,
    Json(req): Json<CreateUserRequest>,
) -> impl IntoResponse

// GET /api/v1/users/:id
async fn get_user(
    State(pool): State<PgPool>,
    Path(id): Path<i64>,
) -> impl IntoResponse

Each handler should:

  1. Call the corresponding UserService method
  2. Return Json(ApiResponse { data: result }) on success
  3. Return an appropriate error via AppError on failure

Prerequisite: Phase 3 models + Phase 4.1 UserService must be complete.

Done when: curl -X POST localhost:3000/api/v1/users ... returns a User JSON object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions