echo

April 18, 2026 · View on GitHub

For when you want labstack/echo instead of net/http. No judgment.

echo/

e, _ := echo.New("/api", swaggerYAML, middlewares)
e.Start(ctx)

Auto-serves OpenAPI spec at OASPath and Swagger UI at SwaggerUIPath. Config from env:

VariableDefault
HTTP_ECHO_LISTENADDRESS0.0.0.0:8080
HTTP_ECHO_OASPATH
HTTP_ECHO_SWAGGERUIPATH

echo/middleware/

OpenAPI request validation + panic recovery + Bearer token auth in one call:

middlewares := echomw.CreateDefaultAPIMiddleware(spec, echomw.BearerAuth(
    func(ctx context.Context, token string) error {
        return validateToken(ctx, token)
    },
))

BearerAuth extracts the token from the Authorization: Bearer <token> header and passes it to your validator. Returns 401 Unauthorized on missing or invalid tokens.

oapi-codegen/middleware/

Wraps oapi-codegen/echo-middleware with structured error responses using aichteeteapee.ErrorResponse.

mw := oapimw.OapiValidatorMiddleware(spec)
mw := oapimw.OapiValidatorMiddlewareWithOptions(spec, opts)

Validation errors return a structured JSON body with the appropriate ErrorCode and human-readable message. Multiple validation errors are joined into a single response.