Skip to content

Recipes for common Go hosts and libraries

Arc exposes a plain http.Handler that you can connect to your service’s router, authentication, tracing and validation libraries. The host must preserve Arc’s method handling and response boundaries, including QUERY and an empty 404 response.

Choose a host recipe and the optional integrations you need. In your application, register commands, queries and any validation callbacks before building Arc. Prepare host-owned resources, start Arc, then serve its handler through the chosen HTTP host. At shutdown, initiate HTTP draining and Arc shutdown together, wait for their outcomes, then close resources such as the tracing provider once the work using them has joined.

You want to Recipe
Mount Arc in a Chi router Chi
Forward unmatched Gin requests to Arc Gin
Delegate Echo v5 requests to Arc Echo
Authenticate bearer tokens with golang-jwt v5 JWT bearer tokens
Serve a frontend on another origin safely CORS and CSRF
Join callers’ traces with otelhttp OpenTelemetry
Validate with go-playground/validator Validation

Every Go block on these pages is an exact excerpt of code in the repository’s recipes module. Its tests serve a small Arc application through each recipe over real HTTP and check commands, /validate, GET and QUERY binding, HEAD, Arc’s empty 404/405 and request cancellation, correlation/privacy headers, direct SSE/WebSocket results, disconnect cleanup and application shutdown, plus each recipe’s own behavior. A documentation test fails when a Go block here no longer matches the tested code.

Run them from the repository root with the module’s own manifest:

Terminal window
cd recipes
GOWORK=off go test ./...

The tests cover the library versions pinned in recipes/go.mod. Other versions may behave differently; run the same tests against yours before you rely on a recipe.

The recipes module is never tagged or published, and Arc’s runtime module does not depend on any of these libraries. Copy the code you need into your application; do not import github.com/cratis/arc.go/recipes. Put copied helpers, their imports and any local declarations in application-owned packages. A helper package prefix in a fragment refers to that copied code, not an import from the unpublished module.

The recipes do not cover databases, message brokers or other optional integrations.