mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 10:35:44 +00:00
20 lines
376 B
Go
20 lines
376 B
Go
package httpx
|
|
|
|
import "golang.org/x/crypto/acme/autocert"
|
|
|
|
type TLS struct {
|
|
CertManager *autocert.Manager
|
|
}
|
|
|
|
func NewTLSConfig(host string) *TLS {
|
|
tls := TLS{
|
|
CertManager: &autocert.Manager{
|
|
Prompt: autocert.AcceptTOS,
|
|
Cache: autocert.DirCache("assets/cache"),
|
|
},
|
|
}
|
|
if host != "" {
|
|
tls.CertManager.HostPolicy = autocert.HostWhitelist(host)
|
|
}
|
|
return &tls
|
|
}
|