httpapi

package
v0.0.0-...-0d253fa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package httpapi provides admin and monitor HTTP servers for the GoBridge runtime. The admin server exposes bridge lifecycle, route inspection, and DLQ management behind mandatory API key authentication. The monitor server exposes unauthenticated health/liveness/readiness probes for orchestrators, plus authenticated endpoints for topology, route detail, and log access. CORS is disabled by default and wildcard origins are rejected at startup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AdminAddr     string `json:"admin_addr"`
	MonitorAddr   string `json:"monitor_addr"`
	AdminAPIKey   string `json:"-"`
	MonitorAPIKey string `json:"-"`
	CORSOrigins   string `json:"cors_origins"`
}

Config holds HTTP server configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with security-first defaults. CORS is disabled (empty origins) and must be explicitly configured. API keys must be set before starting; the server rejects startup without an AdminAPIKey.

type Option

type Option func(*Server)

Option configures a Server.

func WithAuditLogger

func WithAuditLogger(a ports.AuditLogger) Option

WithAuditLogger sets the audit logger for security-relevant operations.

func WithServerLogger

func WithServerLogger(l *slog.Logger) Option

WithServerLogger sets the logger.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server manages the admin and monitor HTTP endpoints.

func New

func New(rt *runtime.Runtime, cfg Config, opts ...Option) *Server

New creates an HTTP Server bound to the given runtime.

func (*Server) MonitorMux

func (s *Server) MonitorMux() *http.ServeMux

MonitorMux returns a ServeMux wired with monitor routes. It is intended for tests and ad-hoc mounting; production servers use Start, which applies middleware around the same route registration.

func (*Server) Start

func (s *Server) Start(_ context.Context) error

Start starts both HTTP servers. It validates configuration, binds listeners synchronously so port conflicts are detected immediately, then serves in background.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully shuts down both HTTP servers.

type SlogAuditLogger

type SlogAuditLogger struct {
	// contains filtered or unexported fields
}

SlogAuditLogger implements ports.AuditLogger by writing structured audit events to a slog.Logger at Info level with an "audit" group.

func NewSlogAuditLogger

func NewSlogAuditLogger(l *slog.Logger) *SlogAuditLogger

NewSlogAuditLogger creates an audit logger that writes to the given slog.Logger.

func (*SlogAuditLogger) Log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL