From dc5daab7558c2c110062f0c52aa6dda4c0965318 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 4 Mar 2020 10:46:31 +0100 Subject: [PATCH] add handler option to http service --- service/http/option.go | 9 +++++++++ service/http/service.go | 1 + 2 files changed, 10 insertions(+) diff --git a/service/http/option.go b/service/http/option.go index 146cd12858..2d7d3c7df6 100644 --- a/service/http/option.go +++ b/service/http/option.go @@ -3,6 +3,7 @@ package http import ( "context" "crypto/tls" + "net/http" "github.com/micro/cli/v2" "github.com/owncloud/ocis-pkg/v2/log" @@ -19,6 +20,7 @@ type Options struct { Name string Version string Address string + Handler http.Handler Context context.Context Flags []cli.Flag } @@ -91,3 +93,10 @@ func TLSConfig(config *tls.Config) Option { o.TLSConfig = config } } + +// Handler sets the http handler for the service +func Handler(h http.Handler) Option { + return func(o *Options) { + o.Handler = h + } +} diff --git a/service/http/service.go b/service/http/service.go index f7e046d6b9..a5f24ecfb2 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -37,6 +37,7 @@ func NewService(opts ...Option) Service { web.RegisterInterval(time.Second * 10), web.Context(sopts.Context), web.TLSConfig(sopts.TLSConfig), + web.Handler(sopts.Handler), web.Flags(sopts.Flags...), }