add handler option to http service

This commit is contained in:
A.Unger committed 2020-03-04 10:46:31 +01:00
1 parent 9bfb89c326
commit dc5daab755
2 files changed
+10

No files matched your search

+9
View File
@@ -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
}
}
+1
View File
@@ -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...),
}