-j
func letsEncryptServe(addr string, dns string, cache string, router http.Handler) {
cacheDir := autocert.DirCache(cache)
m := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist(dns),
Cache: cacheDir,
}
// configure the https server
ssrv := &http.Server{
Handler: router,
Addr: addr,
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
}
fmt.Printf("Server running on %v\n", ssrv.Addr)
// start the ssl server
log.Fatal(ssrv.ListenAndServeTLS("",""))
}
Back on my original question, its ok if i copy paste the code into a specific module with its appropriate credits ?
Given the quick red i gave it, there s really not much to change to this code, it if works already.