engine

package
v1.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(setup App, webConf ...config.WebConf)

Run 启用 Web 服务. 可选传入 webConf, 传入时优先使用, 便于同一应用按不同配置启动并监听不同端口.

func RunGroups added in v1.1.7

func RunGroups(groups ...ServerGroup)

RunGroups 启用多组 Web 服务. 每组使用独立 gin.Engine 和独立路由表, 但复用 config.WebConf 的通用默认项, 适合 API/admin/callback 等业务端口隔离.

func SetTrustedProxies

func SetTrustedProxies() error

SetTrustedProxies 使用当前全局 web_conf 更新所有已启动 gin.Engine 的代理信任配置. 多组监听时每组都有独立 Engine, Runtime reload 需要逐个刷新.

并发说明: Gin 未对 TrustedPlatform / trustedCIDRs 加锁, 在 Engine 服务请求期间写入会与 请求处理路径中的 c.ClientIP() 读取产生数据竞争. 绝大多数 reload 并不改动信任代理配置, 故此处先比对再决定是否修改, 仅在配置确有变化时才写入, 从而消除常规 reload 的竞争窗口. 残留情形(配置确实变更)仍是 best-effort 热更新, 完整无竞争需配合优雅重启(待后续实现).

func SetupExceptionRouter

func SetupExceptionRouter(app *gin.Engine)

SetupExceptionRouter 设置异常请求路由

func SetupSYSRouter

func SetupSYSRouter(app *gin.Engine)

SetupSYSRouter 设置系统信息路由

Types

type App

type App func(app *gin.Engine) *gin.Engine

type ServerGroup added in v1.1.7

type ServerGroup struct {
	Name    string
	WebConf config.WebConf
	Setup   App
}

ServerGroup 描述同一进程内一组独立 gin.Engine 的监听配置和路由注册函数. 适用于一个应用按业务域拆分端口, 避免多个端口共享同一套路由表.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL