middleware

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package middleware provides HTTP middleware for go-httpkit.

Metrics records request count and duration (Prometheus). It accepts an optional Registerer and a PathFromRequest function (e.g. ChiPathFromRequest from httputil).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Metrics

func Metrics(reg prometheus.Registerer, pathFromRequest PathFromRequest) func(http.Handler) http.Handler

Metrics returns middleware that records request count and duration. reg can be nil to use prometheus.DefaultRegisterer. pathFromRequest can be nil.

Types

type PathFromRequest

type PathFromRequest func(*http.Request) string

PathFromRequest returns the route pattern for the request (e.g. from chi.RouteContext). If nil, path will be "/unknown" unless status is 404 then "/not-found".

Jump to

Keyboard shortcuts

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