mirror of
https://github.com/hanzo-fi/webhooks.git
synced 2026-10-30 20:32:55 +00:00
* feat: add audit middleware to webhooks server Wire httpaudit.Middleware from go-libs/v5 into the webhooks HTTP handler to capture and publish audit events via the existing Watermill publisher infrastructure. This was lost when the upgrade PR was squash-merged. * fix: remove duplicate publish module registration The publisher is already provided by the worker module. Adding it again in serve.go causes an fx "already provided" conflict. * fix: move publish module from worker to serve Move publish.FXModuleFromFlags to serve.go so the publisher is available in both server-only and worker modes. Previously it was only in the worker module, causing a missing dependency when running without --worker. --------- Co-authored-by: Hanzo Dev <[email protected]>
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/ThreeDotsLabs/watermill/message"
|
|
"github.com/formancehq/go-libs/v2/otlp"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/formancehq/go-libs/v2/auth"
|
|
"github.com/formancehq/webhooks/pkg/storage"
|
|
|
|
"github.com/formancehq/go-libs/v2/httpserver"
|
|
"github.com/formancehq/go-libs/v2/logging"
|
|
"github.com/formancehq/go-libs/v2/otlp/otlptraces"
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
func FXModuleFromFlags(cmd *cobra.Command, addr string, debug 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)
|
|
},
|
|
), fx.Invoke(func(lc fx.Lifecycle, handler http.Handler) {
|
|
lc.Append(httpserver.NewHook(handler, httpserver.WithAddress(addr)))
|
|
}))
|
|
|
|
return fx.Module("webhooks server", options...)
|
|
}
|