middleware

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chi

func Chi(cfgs ...HTTPConfig) func(http.Handler) http.Handler

Chi returns a chi-compatible middleware with tracing, metrics, and Pyroscope profiling tags. It wraps the standard HTTP middleware and uses chi's route context to tag Pyroscope profiles with the matched route pattern.

func GqlgenExtension

func GqlgenExtension(tracerName string, cfg GqlgenConfig) graphql.HandlerExtension

GqlgenExtension returns a gqlgen handler extension that traces operations and fields, and records Prometheus metrics.

func HTTP

func HTTP(cfgs ...HTTPConfig) func(http.Handler) http.Handler

HTTP returns a net/http middleware that adds tracing and metrics.

Types

type GqlgenConfig

type GqlgenConfig struct {
	// TraceFields enables tracing of individual field resolvers.
	// Disable for performance if you only want operation-level tracing.
	TraceFields bool
}

GqlgenConfig configures the GraphQL extension.

type HTTPConfig

type HTTPConfig struct {
	// IgnorePaths are path prefixes to skip tracing (e.g., "/health", "/metrics").
	IgnorePaths []string
	// IgnoreMethods are HTTP methods to skip (e.g., "OPTIONS").
	IgnoreMethods []string
	// IgnoreProfilePaths are paths excluded from Pyroscope tagging (e.g., GraphQL endpoints
	// that handle their own profiling tags via the GqlgenExtension).
	IgnoreProfilePaths []string
}

HTTPConfig configures the HTTP middleware.

func DefaultHTTPConfig

func DefaultHTTPConfig() HTTPConfig

DefaultHTTPConfig returns a config that ignores OPTIONS and common health/metrics paths.

Jump to

Keyboard shortcuts

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