middleware

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxBytes

func MaxBytes(next http.Handler) http.Handler

MaxBytes limits the request body size to prevent DoS from large payloads.

func OtelRequestResponseLog

func OtelRequestResponseLog(next http.Handler) http.Handler

OtelRequestResponseLog wraps an http.Handler and logs every request and response to stdout, and records request/response attributes on the current OpenTelemetry span. Use inside otelhttp so the span is in context: otelhttp.NewHandler(OtelRequestResponseLog(handler), "ipam").

func Recover

func Recover(next http.Handler) http.Handler

Recover wraps an http.Handler and recovers from panics: logs the panic and stack, returns 500.

func RequestLog

func RequestLog(next http.Handler) http.Handler

RequestLog wraps an http.Handler and logs each request (method, path, status, duration) to stdout. Use with OpenTelemetry: otelhttp.NewHandler(RequestLog(handler), "service name").

func SecurityHeaders

func SecurityHeaders(next http.Handler) http.Handler

SecurityHeaders sets common OWASP-recommended response headers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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