internal/website/docs/architecture/adr-010-unified-gateway.md
Status: Accepted Date: 2026-02-11 Authors: Go Micro Team
Previously, the go-micro CLI had two separate gateway implementations:
micro run gateway (cmd/micro/run/gateway/) - Simple HTTP-to-RPC proxy for developmentmicro server gateway (cmd/micro/server/) - Production gateway with authentication, web UI, and API documentationThis duplication created several problems:
We unified the gateway implementation by:
Extracting reusable gateway module (cmd/micro/server/gateway.go):
GatewayOptions struct for configurationStartGateway() function that returns a *Gateway immediatelyRunGateway() function that blocks until shutdownRefactoring micro server:
cmd/micro/server/registerHandlers() now uses instance-specific *http.ServeMux instead of global muxGatewayOptions.AuthEnabledUpdating micro run:
cmd/micro/run/gateway/)server.StartGateway() with AuthEnabled: truemicro server┌─────────────────────────────────────────────────────────────┐
│ Unified Gateway │
│ (cmd/micro/server/gateway.go) │
│ │
│ • HTTP → RPC translation │
│ • Service discovery via registry │
│ • Web UI (dashboard, logs, API docs) │
│ • Health checks │
│ • Configurable authentication │
│ • Endpoint scopes for access control │
│ • MCP tool integration with scope enforcement │
└─────────────────────────────────────────────────────────────┘
▲ ▲
│ │
┌──────┴──────┐ ┌────────┴────────┐
│ micro run │ │ micro server │
│ │ │ │
│ + Process │ │ + Auth enabled │
│ mgmt │ │ + JWT tokens │
│ + Hot │ │ + Scopes │
│ reload │ │ + Production │
│ + Auth │ │ │
│ + Scopes │ │ │
└─────────────┘ └─────────────────┘
micro run)# Start services with gateway (auth enabled, default admin/micro)
micro run
# Gateway provides:
# - HTTP API at /api/{service}/{endpoint}
# - Web dashboard at /
# - JWT authentication (admin/micro default)
# - Endpoint scopes at /auth/scopes
micro server)# Start gateway with authentication
micro server --address :8080
# Gateway provides:
# - HTTP API at /api/{service}/{endpoint} (auth required)
# - Web dashboard with login
# - JWT-based authentication
# - User/token management UI
# - Endpoint scopes at /auth/scopes
micro server = API gateway (HTTP + future MCP)micro run = Development tool (gateway + process management + hot reload)type GatewayOptions struct {
Address string // Listen address (e.g., ":8080")
AuthEnabled bool // Enable JWT authentication
Store store.Store // Storage for auth data
Context context.Context // Cancellation context
}
// Non-blocking start
gw, err := server.StartGateway(server.GatewayOptions{
Address: ":8080",
AuthEnabled: false,
})
// Blocking start
err := server.RunGateway(server.GatewayOptions{
Address: ":8080",
AuthEnabled: true,
})
When AuthEnabled: true:
/auth/login, /auth/logout, /auth/tokens, /auth/usersAuthorization: Bearer <token> headerWhen AuthEnabled: false (dev mode):
cmd/micro/run now depends on cmd/micro/server (acceptable for CLI tools)micro run (but cleaner overall)With unified gateway architecture, we can now add:
mcp.go to server package, both commands get MCP supportmicro run and micro server