options support for tlsconfig and secure

This commit is contained in:
A.Unger
2020-01-20 10:08:55 +01:00
parent 3dd614fdcd
commit eacf64eb1c
2 changed files with 19 additions and 0 deletions
+17
View File
@@ -2,6 +2,7 @@ package http
import (
"context"
"crypto/tls"
"github.com/micro/cli"
"github.com/owncloud/ocis-pkg/log"
@@ -13,6 +14,8 @@ type Option func(o *Options)
// Options defines the available options for this package.
type Options struct {
Logger log.Logger
Secure bool
TLSConfig *tls.Config
Namespace string
Name string
Version string
@@ -82,3 +85,17 @@ func Flags(flags ...cli.Flag) Option {
o.Flags = append(o.Flags, flags...)
}
}
// Secure provides a function to set the secure option.
func Secure(secure bool) Option {
return func(o *Options) {
o.Secure = secure
}
}
// TLSConfig provides a function to set the TLSConfig option.
func TLSConfig(config *tls.Config) Option {
return func(o *Options) {
o.TLSConfig = config
}
}
+2
View File
@@ -36,6 +36,8 @@ func NewService(opts ...Option) Service {
web.RegisterTTL(time.Second * 30),
web.RegisterInterval(time.Second * 10),
web.Context(sopts.Context),
web.Secure(sopts.Secure),
web.TLSConfig(sopts.TLSConfig),
web.Flags(sopts.Flags...),
}