A thin wrapper around https://echo.labstack.com. Includes
- New Relic integration
- Logrus for structured json logging
- Custom error type
- Custom request context with tracing (correlation ID)
- Go 1.27 or later
- Echo v4 (
github.com/labstack/echo/v4)
Upgrading from v0.1.x requires changes in consuming services:
- Echo v3 → v4. Exported functions (
Echo,EchoHandler,ContextMiddlewareand the other middleware constructors) now take and returngithub.com/labstack/echo/v4types. Change allgithub.com/labstack/echoimports, includingecho/middleware, togithub.com/labstack/echo/v4, then rungo mod tidy. See the Echo v4.0.0 release notes for changes to Echo's own API. - Go 1.27 minimum. The
godirective moved from 1.12 to 1.27, so consumers must build with Go 1.27 or later. - New Relic transaction end errors are logged. A failure to end the New Relic transaction is now logged at error level on the request logger instead of being silently ignored.
The ip field in request logs and New Relic comes from Echo's RealIP(). By default xecho uses
echo.ExtractIPDirect(), so the IP is the connection's remote address and X-Forwarded-For /
X-Real-IP are ignored. Behind a load balancer this is the balancer's IP. Set
Config.IPExtractor to trust forwarding headers only from your proxies:
conf := xecho.NewConfig()
conf.IPExtractor = echo.ExtractIPFromXFFHeader(echo.TrustIPRange(vpcCIDR))ExtractIPFromXFFHeader() trusts loopback, link-local and private ranges by default. Never trust
forwarding headers from addresses a client can reach directly, as the header can be spoofed.
Tool versions are pinned in tools/go.mod and run with go tool, so nothing needs installing globally.
make test- gofmt, go vet and race-enabled testsmake tools- pre-build the pinned toolsmake fmt- format with gofmt and goimportsmake lint- golangci-lintmake vulncheck- govulncheck; fails on reachable vulnerabilities unless listed in the Makefile asVULNCHECK_ACCEPTED(long-term) orVULNCHECK_UNTIL_FIXED(fails once a fix is released). Also runs weekly onmastervia the "Scheduled vulncheck" workflow, which can be triggered manually from the Actions tabmake apidiff- gorelease against the latest tag (needs a clean worktree)