package
1.3.9
Repository: https://github.com/axiaoxin-com/investool.git
Documentation: pkg.go.dev

# README

webserver 包的使用方法

大致流程如下,具体参考 main.go

  1. 加载配置文件,根据配置信息个性化 web server
webserver.InitWithConfigFile(path/to/configfile)
  1. 创建 app 路由
app := webserver.NewGinEngine(nil)
  1. 启动 server
webserver.Run(app)

# Functions

GinBasicAuth gin 的基础认证中间件 加到 gin app 的路由中可以对该路由添加 basic auth 登录验证 传入 username 和 password 对可以替换默认的 username 和 password.
GinLogMiddleware 日志中间件 可根据实际需求自行修改定制.
GinRatelimitMiddleware 限频中间件 需先实现对应的 TODO ,可根据实际需求自行修改定制.
GinRecovery gin recovery 中间件 save err in context and abort with recoveryHandler.
InitWithConfigFile 根据 webserver 配置文件初始化 webserver.
NewGinEngine 根据参数创建 gin 的 router engine middlewares 需要使用到的中间件列表,默认不为 engine 添加任何中间件.
PromExporterHandler return a handler as the prometheus metrics exporter.
Run 以 viper 加载的 app 配置启动运行 http.Handler 的 app 注意:这里依赖 viper ,必须在外部先对 viper 配置进行加载.

# Variables

TemplFuncs is a template.FuncMap with functions that can be used as template actions.