middlewares

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth added in v0.2.1

func BasicAuth(username, password string) string

BasicAuth returns the encoded Basic Authentication header.

func Proxy added in v0.2.1

func Proxy(config ProxyConfig) echo.MiddlewareFunc

Proxy returns a proxy middleware that forwards the request to the target server.

func RequestIdAndDetailsIssuer added in v0.2.2

func RequestIdAndDetailsIssuer(next echo.HandlerFunc) echo.HandlerFunc

RequestIdAndDetailsIssuer is a middleware that issues and tracks request IDs.

This middleware runs BEFORE the Echo handler processes the request. It captures the incoming request, assigns or validates the X-Request-Id, and initializes the request tracking with "Handling" status.

Flow:

  1. Request arrives → this middleware sets status to "Handling"
  2. Calls next(c) to pass control to Echo handler
  3. Echo handler processes the request and writes response
  4. ResponseBodyDump middleware updates status to "Success" or "Error"

func ResponseBodyDump added in v0.4.6

func ResponseBodyDump() echo.MiddlewareFunc

ResponseBodyDump returns a middleware that captures and processes response bodies.

This middleware uses Echo's BodyDump, which wraps the response writer to capture the response body. The Handler function is called AFTER the response is complete, because the response body and HTTP status code are only available once the handler has finished writing the response.

Flow:

  1. Request arrives → request-id middleware sets status to "Handling"
  2. Echo handler processes the request and writes response
  3. BodyDump Handler is called (this middleware) → status updated to "Success" or "Error"

func TracingMiddleware added in v0.2.2

func TracingMiddleware(next echo.HandlerFunc) echo.HandlerFunc

Define Tracing middleware

func TumblebugInitChecker added in v0.2.2

func TumblebugInitChecker(next echo.HandlerFunc) echo.HandlerFunc

TumblebugInitChecker

func Zerologger

func Zerologger(skipPatterns [][]string) echo.MiddlewareFunc

Types

type CustomRoundTripper added in v0.2.1

type CustomRoundTripper struct {
	Transport    http.RoundTripper
	BasicAuthStr string
}

CustomRoundTripper is a custom implementation of http.RoundTripper to modify request headers.

func (*CustomRoundTripper) RoundTrip added in v0.2.1

func (c *CustomRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction and adds custom headers.

type ProxyConfig added in v0.2.1

type ProxyConfig struct {
	URL          *url.URL
	SkipPatterns [][]string
	// Rewrite defines URL path rewrite rules. The values captured in asterisk can be
	// retrieved by index e.g. $1, $2 and so on.
	// Examples:
	// "/old":              "/new",
	// "/api/*":            "/$1",
	// "/js/*":             "/public/javascripts/$1",
	// "/users/*/orders/*": "/user/$1/order/$2",
	Rewrite map[string]string
	// RegexRewrite defines rewrite rules using regexp.Rexexp with captures
	// Every capture group in the values can be retrieved by index e.g. $1, $2 and so on.
	// Example:
	// "^/old/[0.9]+/":     "/new",
	// "^/api/.+?/(.*)":    "/v2/$1",
	RegexRewrite   map[*regexp.Regexp]string
	ModifyResponse func(res *http.Response) error
	Username       string
	Password       string
}

Jump to

Keyboard shortcuts

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