-
Notifications
You must be signed in to change notification settings - Fork 10
/
serve_util.go
40 lines (34 loc) · 770 Bytes
/
serve_util.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
package twig
import (
"crypto/tls"
"net"
"net/http"
)
func NewServerListener(ln net.Listener) Server {
return &httpServer{
twigServer: &twigServer{
Server: &http.Server{},
ln: ln,
},
}
}
func NewServer(addr string) Server {
return NewServerListener(NewKeepAliveListener(addr))
}
func NewServerListenerTLS(ln net.Listener, cert, key string) Server {
return &tlsServer{
twigServer: &twigServer{
Server: &http.Server{},
ln: ln,
},
cert: cert,
key: key,
}
}
func NewServerTLS(addr, cert, key string) Server {
ln := NewKeepAliveListener(addr)
return NewServerListenerTLS(ln, cert, key)
}
func NewServerConfigTLS(ln net.Listener, config *tls.Config) Server {
return NewServerListenerTLS(tls.NewListener(ln, config), "", "")
}