1 Star 0 Fork 0

s-dy / yogurt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
options.go 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
s-dy 提交于 2023-07-28 17:05 . 1
package gin
import (
"crypto/tls"
"time"
"github.com/go-kratos/kratos/v2/middleware"
kHttp "github.com/go-kratos/kratos/v2/transport/http"
)
type ServerOption func(*Server)
func WithTLSConfig(c *tls.Config) ServerOption {
return func(o *Server) {
o.tlsConf = c
}
}
func WithAddress(addr string) ServerOption {
return func(s *Server) {
s.addr = addr
}
}
func WithTimeout(timeout time.Duration) ServerOption {
return func(s *Server) {
s.timeout = timeout
}
}
func WithMiddleware(m ...middleware.Middleware) ServerOption {
return func(o *Server) {
o.ms = m
}
}
func WithFilter(filters ...kHttp.FilterFunc) ServerOption {
return func(o *Server) {
o.filters = filters
}
}
func WithRequestDecoder(dec kHttp.DecodeRequestFunc) ServerOption {
return func(o *Server) {
o.dec = dec
}
}
func WithResponseEncoder(en kHttp.EncodeResponseFunc) ServerOption {
return func(o *Server) {
o.enc = en
}
}
func WithErrorEncoder(en kHttp.EncodeErrorFunc) ServerOption {
return func(o *Server) {
o.ene = en
}
}
func WithStrictSlash(strictSlash bool) ServerOption {
return func(o *Server) {
o.Engine.RedirectTrailingSlash = strictSlash
}
}
1
https://gitee.com/sdynasty/yogurt.git
git@gitee.com:sdynasty/yogurt.git
sdynasty
yogurt
yogurt
01d4da0b550e

搜索帮助