middleware

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 6 Imported by: 0

README

Here are a couple of example middlewares for natsmicromw. The middlewares are:

  • requestid.go: Request ID middleware that parses the header for a request id (storing it into the request context), or generates a unique ID for each request using the header tag 'request_id' or a specified header tag.
  • metrics.go: Metrics middleware that collects Prometheus metrics for NATS messages including the total number of messages received, duration of requests, and size of payloads.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MetricsContextMiddleware added in v0.0.3

func MetricsContextMiddleware(next natsmicromw.ContextHandlerFunc) natsmicromw.ContextHandlerFunc

Same middleware but with context support

func MetricsMiddleware

func MetricsMiddleware(next micro.Handler) micro.Handler

Middleware that increments the message count metric

func RequestIdFromContext

func RequestIdFromContext(ctx context.Context) string

Get current request Id from the context

func RequestIdMiddleware

func RequestIdMiddleware(tags ...string) func(next natsmicromw.ContextHandlerFunc) natsmicromw.ContextHandlerFunc

An example request id middleware

Types

This section is empty.

Jump to

Keyboard shortcuts

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