add tls config to server (#1202)

* add tls config

* add TLSConfig to acme provider
This commit is contained in:
Asim Aslam
2020-02-15 15:10:26 +00:00
committed by GitHub
parent 158949d0d0
commit 964b7dee3f
9 changed files with 114 additions and 18 deletions

View File

@@ -2,6 +2,7 @@ package server
import (
"context"
"crypto/tls"
"sync"
"time"
@@ -39,6 +40,9 @@ type Options struct {
// The router for requests
Router Router
// TLSConfig specifies tls.Config for secure serving
TLSConfig *tls.Config
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
@@ -205,6 +209,19 @@ func RegisterInterval(t time.Duration) Option {
}
}
// TLSConfig specifies a *tls.Config
func TLSConfig(t *tls.Config) Option {
return func(o *Options) {
// set the internal tls
o.TLSConfig = t
// set the transport tls
o.Transport.Init(
transport.Secure(true),
transport.TLSConfig(t),
)
}
}
// WithRouter sets the request router
func WithRouter(r Router) Option {
return func(o *Options) {