(cachePath string, email string, handler http.Handler)
| 30 | } |
| 31 | |
| 32 | func NewAutoHttpsServer(cachePath string, email string, handler http.Handler) *http.Server { |
| 33 | if cachePath == "" { |
| 34 | cachePath = defaultCachePath() |
| 35 | } |
| 36 | log.Infoln("Setting up auto-manager with cache at", cachePath) |
| 37 | |
| 38 | m := autocert.Manager{ |
| 39 | Prompt: autocert.AcceptTOS, |
| 40 | HostPolicy: noByshioHP, |
| 41 | Cache: autocert.DirCache(cachePath), |
| 42 | Email: email, |
| 43 | } |
| 44 | |
| 45 | s := &http.Server{ |
| 46 | Addr: ":https", |
| 47 | TLSConfig: &tls.Config{GetCertificate: m.GetCertificate}, |
| 48 | Handler: handler, |
| 49 | } |
| 50 | |
| 51 | return s |
| 52 | } |
no test coverage detected