# Tasks: Add /hello Endpoint to API Service ## Task Order (dependency sequence) ### T1: Create Hello handler with Say method - **Scope:** Create `services/api/internal/api/handlers/hello.go` with: - `HelloResponse` struct with `Message string` field - `Hello` struct (handler) - `NewHello(logger *logging.Logger) *Hello` constructor - `Say(w http.ResponseWriter, r *http.Request) error` method that returns greeting - **Files:** - Create: `services/api/internal/api/handlers/hello.go` - **Depends on:** None - **Acceptance criteria:** - [ ] `HelloResponse` struct defined with `json:"message"` tag - [ ] `Hello` handler struct created with logger field - [ ] `NewHello` constructor follows existing pattern from `example.go` - [ ] `Say` method uses `httpresponse.OK()` to return `HelloResponse{Message: "Hello, World!"}` - [ ] `Say` method returns `nil` (no error case) - [ ] File compiles without errors ### T2: Add unit tests for Hello handler - **Scope:** Create `services/api/internal/api/handlers/hello_test.go` with test for `Say` method - **Files:** - Create: `services/api/internal/api/handlers/hello_test.go` - **Depends on:** T1 - **Acceptance criteria:** - [ ] Test file follows pattern from `example_test.go` - [ ] `TestHello_Say` test verifies HTTP 200 status - [ ] Test verifies response contains `data` field - [ ] Test verifies `data.message` equals `"Hello, World!"` - [ ] All tests pass ### T3: Register /hello route in routes.go - **Scope:** Update `services/api/internal/api/routes.go` to: - Initialize `helloHandler` using `handlers.NewHello(logger)` - Register `GET /api/v1/hello` route with `app.Wrap(helloHandler.Say)` - **Files:** - Modify: `services/api/internal/api/routes.go` - **Depends on:** T1 - **Acceptance criteria:** - [ ] `helloHandler` initialized alongside other handlers - [ ] Route registered in public routes section (before auth group) - [ ] Route uses `app.Wrap()` pattern - [ ] Route path is `/hello` (under `/api/v1` group) ### T4: Add OpenAPI documentation for /hello endpoint - **Scope:** Update `services/api/internal/api/spec.go` to: - Add "Hello" tag with description "Simple greeting endpoint" - Define `HelloResponse` schema - Add `/api/v1/hello` GET path with response documentation - **Files:** - Modify: `services/api/internal/api/spec.go` - **Depends on:** T3 - **Acceptance criteria:** - [ ] "Hello" tag added with appropriate description - [ ] `HelloResponse` schema defined with `message` field - [ ] GET `/api/v1/hello` path documented - [ ] Response shows 200 with `{data, meta}` envelope containing `HelloResponse` - [ ] No security requirement (public endpoint) - [ ] OpenAPI spec renders correctly at `/docs` ### T5: Verify integration and run quality checks - **Scope:** Run the service and verify end-to-end functionality: - Build passes - Tests pass - Endpoint responds correctly - OpenAPI docs show the new endpoint - **Files:** None (verification only) - **Depends on:** T1, T2, T3, T4 - **Acceptance criteria:** - [ ] `go build ./...` succeeds for services/api - [ ] `go test ./...` passes for services/api - [ ] `GET /api/v1/hello` returns 200 with `{"data": {"message": "Hello, World!"}, "meta": {...}}` - [ ] `/docs` shows Hello endpoint under "Hello" tag - [ ] Response includes `request_id` in meta (via middleware)