Add TLS version of Start

This commit is contained in:
Nise Void 2019-06-11 16:30:58 +02:00
parent 15df08f21b
commit 60f82143da
Signed by: NiseVoid
GPG Key ID: FBA14AC83EA602F3

View File

@ -2,6 +2,7 @@ package router
import ( import (
"context" "context"
"crypto/tls"
"net/http" "net/http"
"reflect" "reflect"
"time" "time"
@ -101,6 +102,13 @@ func (r *Router) Start(addr string) error {
return r.server.ListenAndServe() return r.server.ListenAndServe()
} }
func (r *Router) StartTLS(addr, certFile, keyFile string, conf *tls.Config) error {
httpr := r.getHttpr()
r.server = &http.Server{Addr: addr, Handler: httpr, TLSConfig: conf}
return r.server.ListenAndServeTLS(certFile, keyFile)
}
// Stop stops the web server // Stop stops the web server
func (r *Router) Stop() error { func (r *Router) Stop() error {
if r.server == nil { if r.server == nil {