middleware

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package middleware provides HTTP middleware for the PeeringDB Plus server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORS

func CORS(in CORSInput) func(http.Handler) http.Handler

CORS returns middleware that adds CORS headers per OPS-06. Origins are configured via the AllowedOrigins field.

func Logging

func Logging(logger *slog.Logger) func(http.Handler) http.Handler

Logging returns middleware that logs each HTTP request with method, path, status, duration, and trace context (trace_id, span_id) when available. Uses structured slog per OBS-1, OBS-5 with LogAttrs for attribute-based API.

func Recovery

func Recovery(logger *slog.Logger) func(http.Handler) http.Handler

Recovery returns middleware that recovers from panics in downstream handlers. Logs the panic with stack trace via slog and returns 500 to the client.

Types

type CORSInput

type CORSInput struct {
	// AllowedOrigins is a comma-separated list of allowed origins. Use "*" for all origins.
	AllowedOrigins string
}

CORSInput holds configuration for the CORS middleware.

Jump to

Keyboard shortcuts

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