- Go 98.9%
- Shell 1.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| _fixture | ||
| bind | ||
| echotest | ||
| examples/reference | ||
| fibervisor | ||
| internal | ||
| middleware | ||
| observe | ||
| outcome | ||
| ownerstore | ||
| reqid | ||
| route/pattern | ||
| rows | ||
| server | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| .golangci.yaml | ||
| alloc_guard_test.go | ||
| bind.go | ||
| bind_alloc_guard_test.go | ||
| bind_cache_test.go | ||
| bind_field_error_test.go | ||
| bind_golden_test.go | ||
| bind_test.go | ||
| binder.go | ||
| binder_error_response_test.go | ||
| binder_external_test.go | ||
| binder_generic.go | ||
| binder_generic_external_test.go | ||
| binder_generic_test.go | ||
| binder_test.go | ||
| CHANGELOG.md | ||
| CLAUDE.md | ||
| codecov.yml | ||
| context.go | ||
| context_generic.go | ||
| context_generic_test.go | ||
| context_test.go | ||
| dispatch_pool_test.go | ||
| echo.go | ||
| echo_test.go | ||
| error_handler_differential_test.go | ||
| fibervisor_fit_test.go | ||
| freeze_test.go | ||
| go.mod | ||
| go.sum | ||
| group.go | ||
| group_method_handling_test.go | ||
| group_test.go | ||
| httperror.go | ||
| httperror_external_test.go | ||
| httperror_test.go | ||
| ip.go | ||
| ip_test.go | ||
| json.go | ||
| json_test.go | ||
| LICENSE | ||
| llms-full.txt | ||
| llms.txt | ||
| Makefile | ||
| mx.yml | ||
| observe.go | ||
| observe_external_test.go | ||
| observe_fit_test.go | ||
| observe_test.go | ||
| perf_bench_test.go | ||
| query_fastpath_test.go | ||
| race_off_test.go | ||
| race_on_test.go | ||
| README.md | ||
| readme_example_test.go | ||
| renderer.go | ||
| renderer_test.go | ||
| response.go | ||
| response_test.go | ||
| rfc9457.go | ||
| rfc9457_test.go | ||
| ROADMAP.md | ||
| root_imports_test.go | ||
| route.go | ||
| route_path.go | ||
| route_syntax_test.go | ||
| route_test.go | ||
| router.go | ||
| router_concurrent.go | ||
| router_concurrent_test.go | ||
| router_decode_once_test.go | ||
| router_test.go | ||
| scheme.go | ||
| scheme_test.go | ||
| server.go | ||
| server_stop_external_test.go | ||
| server_test.go | ||
| static_encoded_separator_test.go | ||
| static_path_security_test.go | ||
| trust_alloc_guard_test.go | ||
| trust_header_names_test.go | ||
| trust_serve_golden_test.go | ||
| version.go | ||
| vhost.go | ||
| vhost_test.go | ||
MX Echo v7
MX Echo is a Go HTTP framework derived from LabStack Echo v5.4.6, with the v5.4.7 fixes adapted to v7. Its router, middleware and request-test helpers ship together as one module, github.com/fiberfx/mx-echo/v7. Beside the framework, the module holds standalone packages for typed binding, server lifecycle, route patterns, request outcomes, request names and observation. They use no Echo type, so any http.Handler can use them. A service that the fv supervisor holds can opt into the fibervisor package to state its attempt, name its requests in fv's terms and report how it stopped. Each feature added since v6.3.0 is opt-in: with none of them used, the request path and every default stay as they were.
The minimum Go version is 1.27.4. The latest release is v7.0.2.
Install
go get github.com/fiberfx/mx-echo/v7@v7.0.2
After adding imports such as middleware, run go mod tidy in the application to record the dependencies its packages use.
Serve a request
package main
import (
"log"
"net/http"
"github.com/fiberfx/mx-echo/v7"
"github.com/fiberfx/mx-echo/v7/middleware"
)
func main() {
e := echo.New()
e.Use(middleware.RequestLogger(), middleware.Recover())
e.GET("/hello/:name", func(c *echo.Context) error {
return c.String(http.StatusOK, "Hello, "+c.Param("name")+"!")
})
if err := e.Start(":8080"); err != nil {
log.Fatal(err)
}
}
Run the program with go run .. A request to http://localhost:8080/hello/Ada returns Hello, Ada!. Pre-routing middleware registered with e.Pre runs before the router. Once a route matches, Echo calls its middleware and handler. Returned errors go to HTTPErrorHandler. Handlers have the signature func(*echo.Context) error, and Context is a concrete struct.
Compose a handler without the framework root
This example uses the standalone packages. The caller supplies a context for shutdown. The request handler uses the same integer conversion as an Echo handler.
package service
import (
"context"
"fmt"
"net/http"
"github.com/fiberfx/mx-echo/v7/bind"
"github.com/fiberfx/mx-echo/v7/server"
)
func Serve(ctx context.Context, address string) error {
mux := http.NewServeMux()
mux.HandleFunc("GET /count", func(w http.ResponseWriter, r *http.Request) {
count, err := bind.ParseValueOr[int](r.URL.Query().Get("n"), 1)
if err != nil {
http.Error(w, "n must be an integer", http.StatusBadRequest)
return
}
fmt.Fprintln(w, count)
})
return (server.StartConfig{Address: address}).Start(ctx, mux)
}
Fibervisor's responses service composes an Echo router with the same lifecycle through echo.StartConfig. The supervisor starts one executable, probes its HTTP readiness, and cancels it by process identity. A listener error should reach the command's exit status. HTTP handler and shutdown contracts
Packages
Eight standalone packages were added from v6.2.0 to v6.5.0, and ownerstore in v7.0.0. They share the framework's module and version, and examples/reference composes them with no Echo type.
| Import | Responsibility |
|---|---|
github.com/fiberfx/mx-echo/v7 |
Route registration, request context, binding, responses and server lifecycle |
github.com/fiberfx/mx-echo/v7/bind |
Convert strings and slices with pure functions, including defaults and typed time options |
github.com/fiberfx/mx-echo/v7/server |
Serve any http.Handler with a caller-owned cancellation context, listener and shutdown policy, report how the stop ended and own work that outlives a request |
github.com/fiberfx/mx-echo/v7/route/pattern |
Read a route pattern into its static, parameter and wildcard parts with pure functions |
github.com/fiberfx/mx-echo/v7/outcome |
Classify how a request ended and decide the status of an error response with pure functions |
github.com/fiberfx/mx-echo/v7/reqid |
Name a request with a small value ordered by time, parse an incoming traceparent, and mint and read Ecd IDs (eids), the COR correlation value among them |
github.com/fiberfx/mx-echo/v7/ownerstore |
Keep a service's state in one SQLite file under Ecd ID keys, with the four outcomes of a write (committed, conflict, refused, unknown), a changefeed, durability classes D1 and D2 and one owner at a time |
github.com/fiberfx/mx-echo/v7/observe |
Describe one finished request as a value, write it as JSON and hand it to a sink |
github.com/fiberfx/mx-echo/v7/observe/stdhttp |
Name and observe the requests of any http.Handler, with the standard mux's pattern |
github.com/fiberfx/mx-echo/v7/fibervisor |
Read the attempt the fv supervisor gave the process, state the build, and write observations as JSON lines |
github.com/fiberfx/mx-echo/v7/middleware |
HTTP middleware, including request logging, recovery and compression |
github.com/fiberfx/mx-echo/v7/echotest |
Request contexts, response recorders and fixtures for handler tests |
The root package imports neither fibervisor nor observe/stdhttp, and reads no fv environment. A test holds that rule for every package the root imports.
Run under the fv supervisor (opt-in)
fibervisor is for a service that fv holds. A service that does not import it carries none of it. The package writes no fv record and reaches fv over nothing: it starts no process, no goroutine and no init. Under fv, a service reads its supervision once at start:
package main
import (
"context"
"io"
"net/http"
"os"
"os/signal"
"github.com/fiberfx/mx-echo/v7/fibervisor"
"github.com/fiberfx/mx-echo/v7/observe"
"github.com/fiberfx/mx-echo/v7/observe/stdhttp"
"github.com/fiberfx/mx-echo/v7/server"
)
func main() {
os.Exit(run())
}
func run() int {
ctx, cancel := signal.NotifyContext(context.Background(), fibervisor.StopSignals()...)
defer cancel()
sup, _ := fibervisor.Read() // the zero Supervision when fv does not hold the process
mux := http.NewServeMux()
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, _ *http.Request) {
_, _ = io.WriteString(w, "ok")
})
h := stdhttp.Wrap(mux, observe.Observer{
Sink: fibervisor.LinesOf(os.Stderr, sup),
Attempt: sup.Path,
Build: fibervisor.Build(),
})
var stop server.StopReport
err := (server.StartConfig{
Address: "127.0.0.1:8080",
OnStop: func(r server.StopReport) { stop = r },
}).Start(ctx, h)
return stop.ExitCode(err)
}
What each piece gives:
fibervisor.Readreturns the attempt as aSupervision: the trace, the attempt's path andAttemptNode, the node id thatfv showandfv stopaccept. When fv does not hold the process it returns the zeroSupervisionand false.fibervisor.LinesOfwrites one JSON line per observation, withtraceandattempt_nodeadded, sofv showcan be run from any line. For the zeroSupervision, or a value not in fv's shapes, it writes exactly whatfibervisor.Lineswrites.fibervisor.StopSignalsnames the signals fv stops a leaf with: SIGTERM and an interrupt. The package installs no handler.server.StopReport.ExitCode(err)is the exit status ofmain: 0 after a requested, drained stop; 2 after a requested, forced one; 1 otherwise. It exits nothing. WithOnStopunset, the report is zero and the status is 1.Supervision.RequestNode(id)returns the node id fv would derive for a request under the attempt. It is derived, not recorded, sofv showrefuses it.Supervision.Transport(next)sends each outgoing request whose context names a request with atraceparentnaming that node. Use it as&http.Client{Transport: sup.Transport(nil)}.Supervision.Env(base)gives a child process the environment under whichfv runrecords it as a child of the attempt.Supervision.LinkEnv(base, id)gives one under which fv records a new root in the same trace, linked to the request. A nil base isos.Environ(), as withos/exec.Supervision.Gracereturns the stop grace fv gives the attempt, fromFV_GRACE_MS. fv does not set that variable until its train 2b, so until thenGracereports false: the grace is unknown, not zero.
Each Supervision method returns a new value and changes nothing it is given.
Checked under a real fv (the stand's fv row): fv run starts the reference service; fv show given the attempt_node of one of its lines exits 0 and names the service's pid; fv show refuses a request's id; after fv stop the service drains, exits 0 and leaves no process of its group.
Not yet run under a real fv: Env, LinkEnv, Transport and a forced stop's exit status. Grace waits for fv to set FV_GRACE_MS.
Compatibility
- v7 changes only the module path of v6. An importer replaces
/v6/with/v7/in its import paths; packagemxdbis removed, and nothing else of v6.10.0 moved. v6 stayed source-compatible from v6.1.0 on. Identifiers that moved into a standalone package remain in the root as aliases, such asTimeOptsandErrInvalidCertOrKeyType, andecho.StartConfigremains available. Programs that inspect the defining package ofTimeOptsthrough reflection seegithub.com/fiberfx/mx-echo/v7/bindsince v6.2.0. Each patch release from v6.6.1 to v6.7.1 keeps every exported identifier with the same type, and adds or moves nothing. - New behaviour is opt-in.
Config.Observer,OnStop,server.Owner,Echo.Freezeand thefibervisormethods change nothing until a service uses them. - Defaults are unchanged. With none of the v6.8.0 additions used, the request path and every default are those of v6.7.1.
- No cost when off. With no observer set, the request path is the one of v6.1.0, and a routed request allocates nothing more.
MX Echo follows semantic versioning under the /v7 module path. Minor releases add opt-in API. Patch releases fix behaviour and change no exported identifier.
Upgrading
The published v6.0.0 tag declares the historical module path github.com/fiberfx/echo/v6. When upgrading from v6.0.0, update the imports of the framework, middleware and test helpers together. The Go package name remains echo.
For an application moving from v5, change Echo imports in handlers, middleware and tests together. Go treats types from the two module paths as distinct. A dependency that accepts *echo.Context or returns echo.MiddlewareFunc must use the same module path as its caller. Standard http.Handler implementations can be mounted with echo.WrapHandler.
Open the workspace
Open the directory containing go.mod in GoLand or another Go editor. Run Go commands from that directory.
go version
go list ./...
go test ./...
go vet ./...
go test -race ./...
The go directive sets the minimum supported toolchain. To repeat the contributor checks on this exact patch release, use GOTOOLCHAIN=go1.27.4 make check. make init downloads the module dependencies and installs the pinned linter. Put the Go binary installation directory on your PATH before running make check.
| Target | What it runs |
|---|---|
make check |
The contributor checks: lint, vet and race (the default target) |
make init |
Download module dependencies and install golangci-lint v2.15.0 |
make lint |
golangci-lint with the repository's configuration |
make vet |
go vet ./... |
make test |
Short tests, go test -short ./... |
make race |
The full suite with the race detector |
make benchmark |
Benchmarks with allocation reports |
make test_version |
vet and race in a golang:1.27.4 container |
make help |
List the targets |
GOWORK=off go mod tidy -diff checks the dependency manifest independently of a contributor workspace.
Develop with an application
While developing MX Echo and an application together, put their checkouts under a common parent. For an application module in myapp, run the following from the parent directory. If a workspace already exists there, use go work use ./mx-echo ./myapp to add the modules.
go work init ./mx-echo ./myapp
go -C myapp test ./...
The workspace selects the local MX Echo checkout.
Contributing
Run make check before proposing a change. Use go test -race ./... when changing request handling or shared state. Preserve the order of pre-routing, group and route middleware when changing the request path. Keep package imports under the v6 module path and retain upstream attribution in inherited files. CLAUDE.md maps each responsibility to its source files.
Changes and roadmap
The changelog records every release and retains the upstream history. The roadmap describes the FiberFX line.
Origins and license
MX Echo builds on the work of Vishal Rana, Nitin Rana, Martti T., Roland Lammel, Pablo Andres Fuente and the LabStack Echo contributors. It is released under the MIT terms in LICENSE.