Documentation
¶
Overview ¶
Package middleware provides HTTP middleware components for the application. It includes authentication, CORS, logging, and telemetry middleware.
Package middleware provides HTTP middleware components for the application. It includes authentication, CORS, logging, and telemetry middleware.
Package middleware provides HTTP middleware components for the application. It includes authentication, CORS, logging, and telemetry middleware.
Package middleware provides HTTP middleware components for the application. It includes authentication, CORS, logging, and telemetry middleware.
Package middleware provides HTTP middleware components for the application. It includes authentication, CORS, logging, and telemetry middleware.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
AuthMiddleware is a simple Basic Authentication middleware
func CorsMiddleware ¶
CorsMiddleware is a middleware function that adds CORS headers to the response. It allows all origins, methods, and headers, and handles preflight requests. The middleware then calls the next handler in the chain.
func NewPrometheusMiddleware ¶ added in v1.3.0
func NewPrometheusMiddleware(cnfg Config) *prometheusMiddleware
NewPrometheusMiddleware creates a new PrometheusMiddleware instance
Types ¶
type Config ¶ added in v1.3.0
type Config struct { // Namespace is components of the fully-qualified name of the Metric (created by joining Namespace,Subsystem and Name components with "_") // Optional Namespace string // Subsystem is components of the fully-qualified name of the Metric (created by joining Namespace,Subsystem and Name components with "_") // Defaults to: "golang_rest_api_template" Subsystem string // Buckets specifies an custom buckets to be used in request histograpm. Buckets []float64 // If DoNotUseRequestPathFor404 is true, all 404 responses (due to non-matching route) will have the same `url` label and // thus won't generate new metrics. DoNotUseRequestPathFor404 bool }
Config specifies options how to create new PrometheusMiddleware.
type TelemetryConfig ¶ added in v1.3.0
type TelemetryConfig struct { Host string Port int ServiceName string Trace trace.Tracer Propagators propagation.TextMapPropagator TraceProvider *tracesdk.TracerProvider }
func (*TelemetryConfig) InitTracer ¶ added in v1.3.0
func (c *TelemetryConfig) InitTracer() (*tracesdk.TracerProvider, error)
InitTracer initializes the Jaeger tracer
func (*TelemetryConfig) OpenTelemetryMiddleware ¶ added in v1.3.0
func (c *TelemetryConfig) OpenTelemetryMiddleware(next http.Handler) http.Handler
OpenTelemetryMiddleware is a middleware for tracing HTTP requests