admin

package
v0.0.0-...-c124da1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package admin provides HTTP handlers and types for gofly control-plane endpoints: health, metrics, governance rules and diagnostics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Audit

func Audit(ctx context.Context, sink AuditSink, event AuditEvent)

func AuditMiddleware

func AuditMiddleware(component string, sink AuditSink) func(http.Handler) http.Handler

func AuthorizeBearerOrLocal

func AuthorizeBearerOrLocal(
	w http.ResponseWriter,
	r *http.Request,
	token string,
	writeError ErrorWriter,
) bool

func CleanPathPrefix

func CleanPathPrefix(path string, fallback string) string

func ErrorCode

func ErrorCode(status int) string

func IsSensitiveKey

func IsSensitiveKey(key string) bool

func MaskSensitiveMap

func MaskSensitiveMap(in map[string]string) map[string]string

func WriteError

func WriteError(w http.ResponseWriter, status int, message string)

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, value any)

Types

type AuditEvent

type AuditEvent struct {
	Component  string    `json:"component"`
	Method     string    `json:"method"`
	Path       string    `json:"path"`
	RemoteAddr string    `json:"remoteAddr,omitempty"`
	Status     int       `json:"status"`
	Duration   string    `json:"duration"`
	At         time.Time `json:"at"`
}

AuditEvent records a single admin endpoint invocation.

type AuditSink

type AuditSink func(context.Context, AuditEvent)

AuditSink receives audit events for persistence or forwarding.

func SlogAuditSink

func SlogAuditSink(logger *slog.Logger) AuditSink

type Endpoint

type Endpoint struct {
	Method string
	Path   string
}

Endpoint describes a registered admin HTTP route.

func GovernanceEndpoints

func GovernanceEndpoints(opts ...GovernanceEndpointOption) []Endpoint

type ErrorBody

type ErrorBody struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

ErrorBody carries the error code and human-readable message.

type ErrorResponse

type ErrorResponse struct {
	Error ErrorBody `json:"error"`
}

ErrorResponse is the standard JSON error envelope for admin endpoints.

type ErrorWriter

type ErrorWriter func(http.ResponseWriter, int, string)

ErrorWriter renders an HTTP error response.

type GovernanceEndpointOption

type GovernanceEndpointOption func(*governanceEndpointConfig)

GovernanceEndpointOption customises governance endpoint behaviour.

func WithGovernanceExplain

func WithGovernanceExplain() GovernanceEndpointOption

func WithGovernanceRoot

func WithGovernanceRoot() GovernanceEndpointOption

WithGovernanceRoot enables the root governance endpoint.

Jump to

Keyboard shortcuts

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