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...), }