Added HTTPS support.
This commit is contained in:
parent
337ebb67b4
commit
502e146f92
3 changed files with 28 additions and 4 deletions
12
main.go
12
main.go
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
|
@ -34,6 +35,17 @@ func main() {
|
|||
IdleTimeout: c.Config.HTTP.IdleTimeout,
|
||||
}
|
||||
|
||||
if c.Config.HTTP.TLS.Enabled {
|
||||
certs, err := tls.LoadX509KeyPair(c.Config.HTTP.TLS.Certificate, c.Config.HTTP.TLS.Key)
|
||||
if err != nil {
|
||||
c.Web.Logger.Fatalf("cannot load TLS certificate: %v", err)
|
||||
}
|
||||
|
||||
srv.TLSConfig = &tls.Config{
|
||||
Certificates: []tls.Certificate{certs},
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.Web.StartServer(&srv); err != http.ErrServerClosed {
|
||||
c.Web.Logger.Fatalf("shutting down the server: v", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue