stuff values into context

This commit is contained in:
Joel Wetzell
2025-12-27 22:59:30 -06:00
parent 3458b52206
commit 8ffc7d02a5
21 changed files with 167 additions and 53 deletions

View File

@@ -22,7 +22,13 @@ type HTTPClient struct {
func init() {
RegisterModule(ModuleRegistration{
Type: "http.client",
New: func(ctx context.Context, config config.ModuleConfig, router route.RouteIO) (Module, error) {
New: func(ctx context.Context, config config.ModuleConfig) (Module, error) {
router, ok := ctx.Value(route.RouterContextKey).(route.RouteIO)
if !ok {
return nil, errors.New("http.client unable to get router from context")
}
return &HTTPClient{config: config, ctx: ctx, router: router, logger: CreateLogger(config)}, nil
},
@@ -48,7 +54,7 @@ func (hc *HTTPClient) Run() error {
return nil
}
func (hc *HTTPClient) Output(payload any) error {
func (hc *HTTPClient) Output(ctx context.Context, payload any) error {
payloadRequest, ok := payload.(*http.Request)