gin/examples/auto-tls/example2/main.go
田欧 9ae1e5db2a add package for govendor (#1166)
* add package for govendor

* fix vet error.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* add missing example.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update gin-gonic/autotls

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-11-11 23:11:22 -06:00

27 lines
479 B
Go

package main
import (
"log"
"github.com/gin-gonic/autotls"
"github.com/gin-gonic/gin"
"golang.org/x/crypto/acme/autocert"
)
func main() {
r := gin.Default()
// Ping handler
r.GET("/ping", func(c *gin.Context) {
c.String(200, "pong")
})
m := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist("example1.com", "example2.com"),
Cache: autocert.DirCache("/var/www/.cache"),
}
log.Fatal(autotls.RunWithManager(r, &m))
}