Ai
1 Star 0 Fork 0

Souki/go-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
server_config.go 1019 Bytes
一键复制 编辑 原始数据 按行查看 历史
Souki 提交于 2022-06-26 10:59 +08:00 . add
package httpserver
type ServerOps = func(*HttpServer)
const HealthUrl = "/health"
const RequestIdName = "RequestId"
//default server config
var defaultServerConfig = &ServerConfig{
requestId: true,
requestIdField: RequestIdName,
healthCheck: true,
healthPath: HealthUrl,
acceptOptions: true,
}
type ServerConfig struct {
requestId bool
requestIdField string
//健康检查配置
healthCheck bool
healthPath string
//对options请求自动处理
acceptOptions bool
}
var WithOpsRequestId = func(requestIdField string) ServerOps {
return func(server *HttpServer) {
server.config.requestId = requestIdField != ""
server.config.requestIdField = requestIdField
}
}
var WithOpsHealthCheck = func(add bool, health string) ServerOps {
return func(server *HttpServer) {
server.config.healthCheck = add
server.config.healthPath = health
}
}
var WithOpsAcceptOptions = func(accept bool) ServerOps {
return func(server *HttpServer) {
server.config.acceptOptions = accept
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/scottq/go-framework.git
git@gitee.com:scottq/go-framework.git
scottq
go-framework
go-framework
v1.1.36

搜索帮助