Skip to content

Commit

Permalink
example
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianosela committed Apr 5, 2019
1 parent 75f1f26 commit 2b3b22f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,29 @@ ss.ListenAndServe()
(Using the [certcache](https://godoc.org/github.com/adrianosela/certcache) library to define a cache)

```
ss := sslmgr.NewSecureServer(sslmgr.ServerConfig{
Hostnames: []string{"yourhostname.com"},
Handler: h,
HTTPPort: ":80",
HTTPSPort: ":443",
ReadTimeout: 10 * time.Second(),
WriteTimeout: 10 * time.Second(),
IdleTimeout: 25 * time.Second(),
ServeSSLFunc: func() bool {
return strings.ToLower(os.Getenv("PROD")) == "true"
},
CertCache: certcache.NewFirestore(os.Getenv("FIREBASE_CREDS_PATH"), os.Getenv("FIREBASE_PROJ_ID")),
ss, err := sslmgr.NewSecureServer(sslmgr.ServerConfig{
Hostnames: []string{os.Getenv("CN_FOR_CERTIFICATE")},
HTTPPort: ":80",
HTTPSPort: ":443",
Handler: h,
ServeSSLFunc: func() bool {
return strings.ToLower(os.Getenv("PROD")) == "true"
},
CertCache: certcache.NewLayered(
certcache.NewLogger(),
autocert.DirCache("."),
),
ReadTimeout: 5 * time.Second,
WriteTimeout: 5 * time.Second,
IdleTimeout: 25 * time.Second,
GracefulnessTimeout: 5 * time.Second,
GracefulShutdownErrHandler: func(e error) {
log.Fatal(e)
},
})
if err != nil {
log.Fatal(err)
}
ss.ListenAndServe()
```
8 changes: 8 additions & 0 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"os"
"strings"
"time"

"github.com/adrianosela/certcache"
"github.com/adrianosela/sslmgr"
Expand All @@ -31,6 +32,13 @@ func main() {
certcache.NewLogger(),
autocert.DirCache("."),
),
ReadTimeout: 5 * time.Second,
WriteTimeout: 5 * time.Second,
IdleTimeout: 25 * time.Second,
GracefulnessTimeout: 5 * time.Second,
GracefulShutdownErrHandler: func(e error) {
log.Fatal(e)
},
})
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 2b3b22f

Please sign in to comment.