Skip to content

refactor(api): split internal/api/ into focused subpackages #146

Description

@EricAndrechek

Problem

internal/api/ is the home for the HTTP layer and has grown to encompass: handlers (ingest, query, structured query, SSE, WS, schema, DLQ, policy, pipes), the router, middleware, the Hub, and health endpoints. As more endpoints get added (e.g. K8s-naming /healthz, future admin routes, /version per #44), this single package becomes the place where every PR collides on shared filenames and the Dependencies struct.

Proposed Solution

Split into focused subpackages under internal/api/. Sketch:

  • internal/api/router/ — Chi router, middleware, Hub registration
  • internal/api/ingest/ — ingest handlers
  • internal/api/query/ — raw + structured query handlers, the singleflight cache wiring
  • internal/api/stream/ — SSE + WebSocket
  • internal/api/admin/ — schema, DLQ, policy, pipes admin endpoints
  • internal/api/health/ — health + readiness

Keep the Dependencies struct + the constructor pattern; each subpackage exposes a Register(r chi.Router, deps Dependencies) function called from the top-level wiring.

Additional Context

Adjacent to #140 (refactor(cmd): extract app.App) but addresses a different layer — #140 extracts the wiring out of cmd/wavehouse/main.go::run(); this issue addresses the HTTP package itself. Could be sequenced before or after #140; not blocking either direction.

This is a pure refactor — no functional change, no API surface change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/apiHTTP handlers, routing, middlewarechoreenhancementNew feature or request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions