Documentation
¶
Index ¶
- func BasicAuth(username, password string) string
- func Proxy(config ProxyConfig) echo.MiddlewareFunc
- func RequestIdAndDetailsIssuer(next echo.HandlerFunc) echo.HandlerFunc
- func ResponseBodyDump() echo.MiddlewareFunc
- func TracingMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func TumblebugInitChecker(next echo.HandlerFunc) echo.HandlerFunc
- func Zerologger(skipPatterns [][]string) echo.MiddlewareFunc
- type CustomRoundTripper
- type ProxyConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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:
- Request arrives → this middleware sets status to "Handling"
- Calls next(c) to pass control to Echo handler
- Echo handler processes the request and writes response
- 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:
- Request arrives → request-id middleware sets status to "Handling"
- Echo handler processes the request and writes response
- 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.
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
}