mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-10-25 15:49:18 -04:00
add handler option to http service
This commit is contained in:
2 files changed
+10
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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...),
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user