middlewares

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DecryptValueKey  = "decrypted_body"
	ResponseValueKey = "response_body"

	HeaderJOSE = "application/jose"
)
View Source
const HeaderXTraceID = "X-Trace-ID"

Variables

View Source
var (
	DefaultSpanNameFormatter = func(_ string, r *http.Request) string {
		var b strings.Builder

		b.WriteString(r.Method)
		b.WriteString(":")
		b.WriteString(decreasePathCardinality(r.URL.Path))

		return b.String()
	}

	DefaultFilter = func(r *http.Request) bool {
		if k, ok := r.Header["Upgrade"]; ok {
			for _, v := range k {
				if v == "websocket" {
					return false
				}
			}
		}

		return r.Method != http.MethodGet || !strings.HasPrefix(r.URL.RequestURI(), "/health")
	}
)

Functions

func CORSMiddleware

func CORSMiddleware(methods ...string) http.HandlerFunc

CORSMiddleware implement cors request

func EncryptResponse added in v1.0.8

func EncryptResponse(sesKey, payload []byte) (string, error)

func GetSessionKey added in v1.0.8

func GetSessionKey(masterSecret []byte, nonce []byte) ([]byte, error)

func Metrics added in v1.1.0

func Metrics(client metricRecorder) fiber.Handler

Metrics returns a Fiber middleware that records HTTP request metrics.

func Recover

func Recover(next http.Handler) http.Handler

func RecoverFiber

func RecoverFiber(next fiber.Handler) fiber.Handler

func StartTimingReporter added in v1.1.0

func StartTimingReporter(ctx context.Context)

StartTimingReporter starts a goroutine that logs average response time every interval. Cancel the context to stop it.

func Telemetry

func Telemetry() func(next fiber.Handler) fiber.Handler

func Timing

func Timing(next fiber.Handler) fiber.Handler

Timing calculate time of request

func TimingStats added in v1.1.0

func TimingStats() (time.Duration, int)

TimingStats returns current average response duration and resets counters.

func URLWithoutQuery

func URLWithoutQuery(r *http.Request) string

Types

type JWE added in v1.0.8

type JWE struct {
	// contains filtered or unexported fields
}

func NewJWE added in v1.0.8

func NewJWE(decryptionKeyGetter func(c fiber.Ctx) ([]byte, error)) *JWE

func (*JWE) DecryptMiddleware added in v1.0.8

func (j *JWE) DecryptMiddleware(c fiber.Ctx) error

Jump to

Keyboard shortcuts

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