3.3 KiB
3.3 KiB
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.gowith:HelloResponsestruct withMessage stringfieldHellostruct (handler)NewHello(logger *logging.Logger) *HelloconstructorSay(w http.ResponseWriter, r *http.Request) errormethod that returns greeting
- Files:
- Create:
services/api/internal/api/handlers/hello.go
- Create:
- Depends on: None
- Acceptance criteria:
HelloResponsestruct defined withjson:"message"tagHellohandler struct created with logger fieldNewHelloconstructor follows existing pattern fromexample.goSaymethod useshttpresponse.OK()to returnHelloResponse{Message: "Hello, World!"}Saymethod returnsnil(no error case)- File compiles without errors
T2: Add unit tests for Hello handler
- Scope: Create
services/api/internal/api/handlers/hello_test.gowith test forSaymethod - Files:
- Create:
services/api/internal/api/handlers/hello_test.go
- Create:
- Depends on: T1
- Acceptance criteria:
- Test file follows pattern from
example_test.go TestHello_Saytest verifies HTTP 200 status- Test verifies response contains
datafield - Test verifies
data.messageequals"Hello, World!" - All tests pass
- Test file follows pattern from
T3: Register /hello route in routes.go
- Scope: Update
services/api/internal/api/routes.goto:- Initialize
helloHandlerusinghandlers.NewHello(logger) - Register
GET /api/v1/helloroute withapp.Wrap(helloHandler.Say)
- Initialize
- Files:
- Modify:
services/api/internal/api/routes.go
- Modify:
- Depends on: T1
- Acceptance criteria:
helloHandlerinitialized alongside other handlers- Route registered in public routes section (before auth group)
- Route uses
app.Wrap()pattern - Route path is
/hello(under/api/v1group)
T4: Add OpenAPI documentation for /hello endpoint
- Scope: Update
services/api/internal/api/spec.goto:- Add "Hello" tag with description "Simple greeting endpoint"
- Define
HelloResponseschema - Add
/api/v1/helloGET path with response documentation
- Files:
- Modify:
services/api/internal/api/spec.go
- Modify:
- Depends on: T3
- Acceptance criteria:
- "Hello" tag added with appropriate description
HelloResponseschema defined withmessagefield- GET
/api/v1/hellopath documented - Response shows 200 with
{data, meta}envelope containingHelloResponse - 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/apigo test ./...passes for services/apiGET /api/v1/helloreturns 200 with{"data": {"message": "Hello, World!"}, "meta": {...}}/docsshows Hello endpoint under "Hello" tag- Response includes
request_idin meta (via middleware)