Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <[email protected]>
  • Loading branch information
appleboy committed Apr 17, 2017
1 parent 2da1729 commit f8520b8
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 58 deletions.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,65 @@ func main() {
}
```

### Support Let's Encrypt

example for 1-line LetsEncrypt HTTPS servers.

[embedmd]:# (examples/auto-tls/example1.go go)
```go
package main

import (
"log"

"github.com/gin-gonic/autotls"
"github.com/gin-gonic/gin"
)

func main() {
r := gin.Default()

// Ping handler
r.GET("/ping", func(c *gin.Context) {
c.String(200, "pong")
})

log.Fatal(autotls.Run(r, "example1.com", "example2.com"))
}
```

example for custom autocert manager.

[embedmd]:# (examples/auto-tls/example2.go go)
```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))
}
```

### Graceful restart or stop

Do you want to graceful restart or stop your web server?
Expand Down
19 changes: 19 additions & 0 deletions examples/auto-tls/example1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"log"

"github.com/gin-gonic/autotls"
"github.com/gin-gonic/gin"
)

func main() {
r := gin.Default()

// Ping handler
r.GET("/ping", func(c *gin.Context) {
c.String(200, "pong")
})

log.Fatal(autotls.Run(r, "example1.com", "example2.com"))
}
26 changes: 26 additions & 0 deletions examples/auto-tls/example2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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))
}
21 changes: 0 additions & 21 deletions examples/auto-tls/main.go

This file was deleted.

37 changes: 0 additions & 37 deletions gin1.7.go

This file was deleted.

0 comments on commit f8520b8

Please sign in to comment.