Documentation
¶
Overview ¶
Package apiserver builds the process HTTP handler: the typed Huma /v1 surface (internal/httpapi) wrapping the legacy gorilla/mux fallback.
It exists so the production binary (cmd/e2a) and the contract-test harness (internal/testutil) construct the SAME handler from the SAME dependency wiring. Before this, the contract harness served only the legacy mux, so it could not exercise /v1 at all and would silently drift from production. With one builder, a dep that production wires but the harness forgets shows up as a failing contract test, not a silent gap.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Params ¶
type Params struct {
API *agent.API
Store *identity.Store
Enforcer *limits.DBEnforcer
UsageStore *usage.Store
SubscriberStore *webhook.SubscriberStore
Idempotency *idempotency.Store
Pool *pgxpool.Pool
SMTPDomain string
PublicURL string
Production bool
// SESRegion is the SES sending-identity region (config
// sender_identity.ses_region). Non-empty enables the sending feature, which
// makes domainView emit the deterministic mail_from_* DNS records. Mirrors
// the gate used to wire SenderIdentity below.
SESRegion string
// SigningSecret is the deployment HMAC secret (config.Signing.HMACSecret) —
// used to mint/verify short-lived attachment download tokens (§6a #5), the
// same primitive as the HITL magic-link. When empty, attachment endpoints
// are left unwired.
SigningSecret string
// EventsEnabled mirrors the outbox's flag (now unconditional in production).
// When false the webhook_events durable log is never written, so the events
// list/get/redeliver endpoints return 501 events_log_disabled instead of an
// empty result. Webhook delivery (River) is unaffected.
EventsEnabled bool
// Legacy is the gorilla/mux handler the chi root falls back to for any
// route not on /v1. WSHandle serves the /v1 WebSocket upgrade.
Legacy http.Handler
WSHandle func(w http.ResponseWriter, r *http.Request, address string)
// SenderIdentity (decision 4 / Slice 4) schedules SES sending-identity
// provisioning on domain verify and teardown on domain delete. Optional —
// nil when SES is not configured (dev/self-host), leaving sending_status
// at none and the relay From in place. *senderidentity.Manager satisfies it.
SenderIdentity SenderIdentityEnqueuer
// EnqueueDelivery enqueues a River webhook_deliver job for a
// webhook_subscriber_deliveries row inserted directly by the /test endpoint
// or the event-redelivery API (both bypass the outbox drain). River is the
// sole delivery engine, so without this those rows would never deliver.
// Wired from *webhookdelivery.Jobs.EnqueueDelivery in the binary. Optional —
// nil in minimal test setups with no River client.
EnqueueDelivery func(ctx context.Context, deliveryID string) error
// AgentSuppressionAddedHook writes the beta suppression event in the same
// transaction as any newly inserted agent suppression, whether it came from
// authenticated management or a recipient token. Optional until the event
// slice is wired by the caller.
AgentSuppressionAddedHook identity.AgentSuppressionTxHook
ManagedUnsubscribeIssuer agent.ManagedUnsubscribeIssuer
}
Params bundles the already-constructed components the /v1 Deps closures bind to. Callers build these once (the binary for real, the harness for tests) and hand them over; the builder owns only the mapping into httpapi.Deps.
type SenderIdentityEnqueuer ¶
type SenderIdentityEnqueuer interface {
EnqueueProvision(ctx context.Context, domain string) error
EnqueueDeprovisionTx(ctx context.Context, tx pgx.Tx, domain string) error
}
SenderIdentityEnqueuer is the slice of *senderidentity.Manager apiserver needs. Defined as an interface so apiserver does not hard-depend on the senderidentity package (River + AWS SDK) just to wire two optional deps.