webhook
webhook copied to clipboard
Accepting dynamic values in URI path
Is it possible to accept a dynamic webhook ID?
I want to be able to accept a POST request like /hooks/path/to/{DYNAMIC_ID} of-course without knowing the DYNAMIC_ID ahead of time. Looking around I'm not sure if this is possible but would appreciate any resources that point in the right direction.
Not currently possible. What system are you using that sends such a request?
Sadly I think due to this issue and #421 I'll have to look at another webhook library for my needs but I want to thank you for your time @moorereason I appreciate the thorough responses.
Thanks for the link. I guess the CopyLeaks folks thought that was clever, but it really complicates the hook receiver. Oh well.
Thinking out loud about how we might add support for dynamic hook paths like CopyLeaks...
#421 is a prerequisite only if you need multiple path segments. Assuming you would in more cases.
I think we would need to allow the hook ID to contain mux path variables. One downside: it could expose the mux path parser syntax to the user, which would make it harder to switch away from Gorilla later.
"id": "{status}/{scan_id}"
We could match that request, but each hook would likely need its own HTTP handler func since we wouldn't necessarily know which route the mux matched.
We would also need a way to pass the individual variables (status & scan_id) down the stack.
Hmm. Sounds like a lot of refactoring. Something to ponder...