Skip to content

Commit a370fab

Browse files
intel352claude
andcommitted
fix: remove DefaultServeMux registration and expose webhook route via ConfigFragment
http.HandleFunc on the global DefaultServeMux is never reachable from the engine because the plugin runs as a separate gRPC process. Removed the http.HandleFunc call from Start() and implemented sdk.ConfigProvider on githubPlugin, returning a config fragment that declares the /webhooks/github HTTP route so the engine's own HTTP server registers it through the normal config pipeline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f83b48e commit a370fab

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

internal/module_webhook.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,9 @@ func (m *webhookModule) SetMessageSubscriber(_ sdk.MessageSubscriber) {}
100100
// Init is a no-op; the module is ready after construction.
101101
func (m *webhookModule) Init() error { return nil }
102102

103-
// Start registers the HTTP webhook handler with the global mux.
104-
// The engine must be running its HTTP server for this to receive requests.
105-
func (m *webhookModule) Start(_ context.Context) error {
106-
http.HandleFunc("/webhooks/github", m.handleWebhook)
107-
return nil
108-
}
103+
// Start is a no-op; the webhook route is declared via ConfigFragment so the
104+
// engine's HTTP server registers it through the normal config pipeline.
105+
func (m *webhookModule) Start(_ context.Context) error { return nil }
109106

110107
// Stop is a no-op.
111108
func (m *webhookModule) Stop(_ context.Context) error { return nil }

internal/plugin.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ import (
66
sdk "github.com/GoCodeAlone/workflow/plugin/external/sdk"
77
)
88

9+
// webhookRouteConfig is the config fragment YAML that declares the GitHub
10+
// webhook HTTP route so the engine's HTTP server registers it via the normal
11+
// config pipeline instead of the unreachable global DefaultServeMux.
12+
const webhookRouteConfig = `
13+
workflows:
14+
github-webhook-receiver:
15+
triggers:
16+
- type: http
17+
config:
18+
path: /webhooks/github
19+
method: POST
20+
steps: []
21+
`
22+
923
// githubPlugin implements sdk.PluginProvider, sdk.ModuleProvider, and sdk.StepProvider.
1024
type githubPlugin struct{}
1125

@@ -61,3 +75,11 @@ func (p *githubPlugin) CreateStep(typeName, name string, config map[string]any)
6175
return nil, fmt.Errorf("github plugin: unknown step type %q", typeName)
6276
}
6377
}
78+
79+
// ConfigFragment implements sdk.ConfigProvider.
80+
// It returns a config fragment that declares the /webhooks/github HTTP route
81+
// so the engine registers it through the normal config pipeline rather than
82+
// through the global DefaultServeMux (which is unreachable in a gRPC plugin).
83+
func (p *githubPlugin) ConfigFragment() ([]byte, error) {
84+
return []byte(webhookRouteConfig), nil
85+
}

0 commit comments

Comments
 (0)