extmiddleware

package module
v0.0.0-...-9a4a462 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 12 Imported by: 0

README

Chi Extra Middleware

This package provides additional middleware

Extra Middleware

  • ZeroLogger - logs all incoming requests with their latency using zerolog
  • RealIP - detects user real ip address
  • Metrics - prometheus metrics for incoming requests

Install

go get -u github.com/ferluci/chi-extra-middleware

Examples

Here

Inspired By

Tomasen RealIP

Request IP

Globocom Echo Prometheus

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBuckets = []float64{
	0.00001,
	0.0001,
	0.001,
	0.002,
	0.005,
	0.01,
	0.02,
	0.05,
	0.1,
	0.2,
	0.5,
	1.0,
	2.0,
	5.0,
}
View Source
var DefaultConfig = Config{
	Namespace: "chi",
	Subsystem: "http",
	Buckets:   DefaultBuckets,
}

DefaultConfig has the default instrumentation config

Functions

func Metrics

func Metrics() func(next http.Handler) http.Handler

Metrics returns an echo middleware with default config for instrumentation.

func MetricsWithConfig

func MetricsWithConfig(config Config) func(next http.Handler) http.Handler

func RealIP

func RealIP(h http.Handler) http.Handler

func ZeroLogger

func ZeroLogger() func(next http.Handler) http.Handler

Types

type Config

type Config struct {
	Namespace string
	Buckets   []float64
	Subsystem string
}

Config responsible to configure middleware

func NewConfig

func NewConfig() Config

NewConfig returns a new config with default values

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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