package main import ( "apigo.cc/go/config" "apigo.cc/go/log" "apigo.cc/go/starter" "time" ) func main() { // 1. 加载默认配置,支持覆盖与环境变量注入 _ = config.Load(&GatewayConf, "gateway") // 2. 初始化 Starter 信息 starter.SetAppInfo("gateway", "2.0.1") starter.SetUsage(`High-performance, event-driven dynamic API gateway. Configuration: Uses env.yml or environment variables for base configuration. Supports Nginx-like static routing via Proxy/Rewrite/Static declarations in yaml. Supports real-time atomic hot-reloading via Redis Pub/Sub. Routing Path Matching: - Exact Match (Default): Path: "/api" matches EXACTLY "/api" - Fast Prefix Match: Path: "/api/*" matches any path starting with "/api/" - Regex Match: Path: "^/api/(.*)$" captures groups for replacement in ToPath Host Matching (Fallback Order): 1. Exact Host+Port (e.g., "aa.com:8080") 2. Host Only (e.g., "aa.com") 3. Port Only (e.g., ":8080") 4. Global Wildcard (e.g., "*" or "")`) // 3. 注册 Gateway 服务 // GatewayApp 自身实现了 starter.Service 和 starter.Reloader 接口 app := NewGatewayApp() starter.Register("gateway-core", app, 100, 5*time.Second, 10*time.Second) // 4. 运行服务生命周期,响应 start/stop/reload 等命令 starter.Run() log.DefaultLogger.Info("gateway process exited") }