options support for tlsconfig and secure
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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...),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user