caddy-webhook icon indicating copy to clipboard operation
caddy-webhook copied to clipboard

Webhook handler doesn't work when defined in a json config file

Open smanierre opened this issue 2 years ago • 0 comments

I have a caddy server running with my config defined in a JSON file instead of a caddy file. Whenever I hit my webhook endpoint I get the following error: {"level":"debug","ts":1665975832.1216764,"logger":"http.log.error","msg":"page not found","request":{"remote_ip":"***.***.***.***","remote_port":"29294","proto":"HTTP/2.0","method":"GET","host":"valid.hostname","uri":"/webhook","headers":{"Te":["trailers"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"],"Accept-Language":["en-US,en;q=0.5"],"Accept-Encoding":["gzip, deflate, br"],"Upgrade-Insecure-Requests":["1"],"Sec-Fetch-Dest":["document"],"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-Site":["none"],"Sec-Fetch-User":["?1"]},"tls":{"resumed":true,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"server.name"}},"duration":0.000027586,"status":404,"err_id":"gyp8k3bjm","err_trace":"caddy-webhook.(*WebHook).ServeHTTP (webhook.go:221)"} Here is the config i'm using for the webhook endpoint: { "match": [ { "host": ["*hostname"], "path": ["/webhook"] } ], "handle": [ { "handler": "webhook", "repo": "[email protected]:user/repo", "path": "/home/user/caddy_webhooks", "branch": "master", "type": "gitlab", "secret": "{env.WEBHOOK_SECRET}", "command": ["ls"] } ], "terminal": true }

Looking in the source code, it looks like Webhook.setup is never set to true, and I looked around a bit and it seemed like it may because it's only setup to read from a caddy file not a json file.

smanierre avatar Oct 17 '22 03:10 smanierre