middleware

package
v0.0.0-...-ad4e74a Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(h http.Handler, middlewares ...Middleware) http.Handler

Wrap handler using given middlewares.

Types

type MetricsProvider

type MetricsProvider struct {
	TracerProvider    trace.TracerProvider
	MeterProvider     metric.MeterProvider
	TextMapPropagator propagation.TextMapPropagator
}

type Middleware

type Middleware = func(http.Handler) http.Handler

Middleware is a net/http middleware.

func InjectLogger

func InjectLogger(lg *slog.Logger) Middleware

InjectLogger injects logger into request context.

func Instrument

func Instrument(serviceName string, find RouteFinder, m MetricsProvider) Middleware

Instrument setups otelhttp.

func Labeler

func Labeler(find RouteFinder) Middleware

func LogRequests

func LogRequests(find RouteFinder) Middleware

LogRequests logs incoming requests using context logger.

type Route

type Route interface {
	Name() string
	OperationID() string
	PathPattern() string
}

Route is a generic ogen route type.

type RouteFinder

type RouteFinder func(method string, u *url.URL) (Route, bool)

RouteFinder finds Route by given URL.

func MakeRouteFinder

func MakeRouteFinder[R Route, S Server[R]](server S) RouteFinder

MakeRouteFinder creates RouteFinder from given server.

type Server

type Server[R Route] interface {
	FindPath(method string, u *url.URL) (r R, _ bool)
}

Server is a generic ogen server type.

Jump to

Keyboard shortcuts

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