Skip to content

feat(go-api): wire REST endpoints, gRPC client, and request middleware#30

Open
Depo-dev wants to merge 4 commits into
devfrom
feat/issue-14-go-rest-endpoints
Open

feat(go-api): wire REST endpoints, gRPC client, and request middleware#30
Depo-dev wants to merge 4 commits into
devfrom
feat/issue-14-go-rest-endpoints

Conversation

@Depo-dev

@Depo-dev Depo-dev commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements the three core REST endpoints backed by the Rust gRPC API, plus request middleware.

What's included

  • proto/trident.proto — adds go_package option for Go codegen
  • buf.yaml + buf.gen.yaml — buf configuration for Go proto generation
  • services/api/internal/proto/ — committed generated Go gRPC client (buf-generated)
  • services/api/handlers/events.goGET /v1/health, GET /v1/events, GET /v1/events/{id}; proxies to gRPC, maps codes.NotFound → 404, codes.InvalidArgument → 400
  • services/api/handlers/events_test.go — 5 httptest-based tests using a mock EventsClient
  • services/api/middleware/logging.goRequestID (rand hex + X-Request-ID header) and Logging (slog JSON: method/path/status/latency_ms/request_id)
  • services/api/main.go — wires gRPC dial (GRPC_API_ADDR env, default localhost:50051), registers routes, chains middleware
  • services/api/go.mod/go.sum — adds grpc, protobuf, pgx/v5, go-redis/v9

Tests

ok  github.com/Depo-dev/trident/services/api/handlers  (5 tests pass)
go vet: clean

Closes #14

Depo-dev added 4 commits June 3, 2026 16:16
Generates Go proto bindings from proto/trident.proto using buf. Wires
three REST handlers (GET /v1/health, GET /v1/events, GET /v1/events/{id})
that proxy to the Rust gRPC API via google.golang.org/grpc. Adds
RequestID middleware (random hex ID in context + X-Request-ID header) and
Logging middleware (slog JSON: method/path/status/latency/request_id).
All four deps added to go.mod: grpc, protobuf, pgx/v5, go-redis/v9.
Handler tests use a mock EventsClient and httptest; all pass with go vet
clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant