Documentation
¶
Overview ¶
Package admin provides HTTP handlers and types for gofly control-plane endpoints: health, metrics, governance rules and diagnostics.
Index ¶
- func Audit(ctx context.Context, sink AuditSink, event AuditEvent)
- func AuditMiddleware(component string, sink AuditSink) func(http.Handler) http.Handler
- func AuthorizeBearerOrLocal(w http.ResponseWriter, r *http.Request, token string, writeError ErrorWriter) bool
- func CleanPathPrefix(path string, fallback string) string
- func ErrorCode(status int) string
- func IsSensitiveKey(key string) bool
- func MaskSensitiveMap(in map[string]string) map[string]string
- func WriteError(w http.ResponseWriter, status int, message string)
- func WriteJSON(w http.ResponseWriter, status int, value any)
- type AuditEvent
- type AuditSink
- type Endpoint
- type ErrorBody
- type ErrorResponse
- type ErrorWriter
- type GovernanceEndpointOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuditMiddleware ¶
func AuthorizeBearerOrLocal ¶
func AuthorizeBearerOrLocal( w http.ResponseWriter, r *http.Request, token string, writeError ErrorWriter, ) bool
func CleanPathPrefix ¶
func IsSensitiveKey ¶
func WriteError ¶
func WriteError(w http.ResponseWriter, status int, message string)
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 ¶
type Endpoint ¶
Endpoint describes a registered admin HTTP route.
func GovernanceEndpoints ¶
func GovernanceEndpoints(opts ...GovernanceEndpointOption) []Endpoint
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.
Click to show internal directories.
Click to hide internal directories.