blob: 366aeb5db81ee3742b24cd5d8ae7c1d22488ffa5 (
plain)
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
|
package gitlabstub
import (
"crypto/tls"
"net/http"
"time"
)
type config struct {
pagesHandler http.HandlerFunc
pagesRoot string
delay time.Duration
tlsConfig *tls.Config
}
type Option func(*config)
func defaultTLSConfig() *tls.Config {
return &tls.Config{
MinVersion: tls.VersionTLS12,
}
}
func WithPagesHandler(ph http.HandlerFunc) Option {
return func(sc *config) {
sc.pagesHandler = ph
}
}
func WithPagesRoot(pagesRoot string) Option {
return func(sc *config) {
sc.pagesRoot = pagesRoot
}
}
func WithDelay(delay time.Duration) Option {
return func(sc *config) {
sc.delay = delay
}
}
func WithCertificate(cert tls.Certificate) Option {
return func(c *config) {
if c.tlsConfig == nil {
c.tlsConfig = defaultTLSConfig()
}
c.tlsConfig.Certificates = append(c.tlsConfig.Certificates, cert)
}
}
|