From eacf64eb1c64f3d3d79b2bc496c7f2564972c7d7 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Mon, 20 Jan 2020 10:08:55 +0100 Subject: [PATCH] options support for tlsconfig and secure --- service/http/option.go | 17 +++++++++++++++++ service/http/service.go | 2 ++ 2 files changed, 19 insertions(+) diff --git a/service/http/option.go b/service/http/option.go index 73ea43428b..21eb677222 100644 --- a/service/http/option.go +++ b/service/http/option.go @@ -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 + } +} diff --git a/service/http/service.go b/service/http/service.go index c77dcaae2f..d3ca3b39dc 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -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...), }