middlewares

package
v2.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthCheckMiddleware

func HealthCheckMiddleware(next http.Handler) http.Handler

HealthCheckMiddleware provides the GET /healthcheck endpoint.

func RecoveryMiddleware added in v2.5.3

func RecoveryMiddleware(next http.Handler) http.Handler

RecoveryMiddleware catches panics from downstream handlers, logs them with a stack trace, and writes a plain 500 response. It is intended to wrap the Sentry handler (configured with Repanic: true) so that Sentry reports the panic first and this middleware then converts it into a real HTTP 500.

The 500 is written via WriteHeader so that any outer Prometheus instrumentation observes the correct status code.

Types

type AuditController

type AuditController struct {
	Auditor audittools.Auditor
}

func NewAuditController

func NewAuditController() (*AuditController, error)

func (*AuditController) AuditHandler

func (ac *AuditController) AuditHandler(next http.Handler) http.Handler

AuditHandler provides the audit handling.

func (*AuditController) NewAuditResponseWriter

func (ac *AuditController) NewAuditResponseWriter(w http.ResponseWriter, r *http.Request, body []byte) *AuditResponseWriter

type AuditResource

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

AuditResource is an audittools.EventRenderer.

func (AuditResource) Render

func (a AuditResource) Render() cadf.Resource

Render implements the audittools.EventRenderer interface.

type AuditResponseWriter

type AuditResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

AuditResponseWriter is a wrapper of regular ResponseWriter

func (*AuditResponseWriter) Write added in v2.5.3

func (arw *AuditResponseWriter) Write(b []byte) (int, error)

Write implements http.ResponseWriter. The stdlib will invoke WriteHeader(200) on the first Write if the handler hasn't called it explicitly — we need to funnel that through our wrapper so the implicit 200 also records an audit event.

func (*AuditResponseWriter) WriteHeader

func (arw *AuditResponseWriter) WriteHeader(code int)

Jump to

Keyboard shortcuts

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