-
Notifications
You must be signed in to change notification settings - Fork 80
/
options.go
64 lines (52 loc) · 1.1 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package hertz
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) {
}
}