mirror of
https://github.com/hanzo-fi/webhooks.git
synced 2026-10-30 20:32:55 +00:00
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/ThreeDotsLabs/watermill/message"
|
|
"github.com/hanzo-fi/go-libs/v2/otlp"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/hanzo-fi/go-libs/v2/auth"
|
|
"github.com/hanzo-fi/webhooks/pkg/storage"
|
|
|
|
"github.com/hanzo-fi/go-libs/v2/httpserver"
|
|
"github.com/hanzo-fi/go-libs/v2/logging"
|
|
"github.com/hanzo-fi/go-libs/v2/otlp/otlptraces"
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
func FXModuleFromFlags(cmd *cobra.Command, addr string, debug bool, auditEnabled bool) fx.Option {
|
|
var options []fx.Option
|
|
|
|
options = append(options,
|
|
otlp.FXModuleFromFlags(cmd),
|
|
otlptraces.FXModuleFromFlags(cmd),
|
|
)
|
|
|
|
options = append(options, fx.Provide(
|
|
func(
|
|
store storage.Store,
|
|
httpClient *http.Client,
|
|
logger logging.Logger,
|
|
info ServiceInfo,
|
|
authenticator auth.Authenticator,
|
|
publisher message.Publisher,
|
|
) http.Handler {
|
|
return newServerHandler(store, httpClient, logger, info, authenticator, publisher, debug, auditEnabled)
|
|
},
|
|
), fx.Invoke(func(lc fx.Lifecycle, handler http.Handler) {
|
|
lc.Append(httpserver.NewHook(handler, httpserver.WithAddress(addr)))
|
|
}))
|
|
|
|
return fx.Module("webhooks server", options...)
|
|
}
|