Conversation
bbb3a44 to
d6774bf
Compare
Signed-off-by: Piotr Pawluk <piotr.pawluk@zendesk.com>
24cf799 to
9bd4c5d
Compare
|
Rebased |
lukemassa
left a comment
There was a problem hiding this comment.
Nice! I left a few small comments but overall nice addition!
server/events/webhooks/http.go
Outdated
| } | ||
|
|
||
| // RoundTrip handles each http request. | ||
| func (t *AuthedTransport) RoundTrip(req *http.Request) (*http.Response, error) { |
There was a problem hiding this comment.
https://pkg.go.dev/net/http#RoundTripper says
RoundTrip should not modify the request, except for consuming and closing the Request's Body
I'm not very familiar with the http package, so I'm not sure what the implications are if the request is modified (or if adding headers qualifies as "modifying"), any thoughts here?
As an alternative you could always pass the headers into the webhook itself then set them on doSend()
There was a problem hiding this comment.
I'm not very familiar with the http package, so I'm not sure what the implications are if the request is modified (or if adding headers qualifies as "modifying"), any thoughts here?
The oauth package does the same pattern for authorization and I initially planned to follow (even forgot to change name) but maybe it's an overkill; adding headers explicitly will be less confusing.
There was a problem hiding this comment.
Yeah, as long as it doesn't complicate doSend() too much it might be worth it.
Also looking at that example, it looks like it actually makes a clone of the request, I assume to comply w the part of the doc I quoted above?
req2 := cloneRequest(req) // per RoundTripper contract
If it ends up being better to do this via a RoundTripper, I wonder if this might be a better approach?
There was a problem hiding this comment.
Yeah I just went with adding headers explicitly in 5939aad
server/events/webhooks/http.go
Outdated
| return nil | ||
| } | ||
|
|
||
| func (h *HttpWebhook) doSend(_ logging.SimpleLogging, applyResult ApplyResult) error { |
There was a problem hiding this comment.
Since doSend() is a non-exported method (i.e. unlike Send()) you should be able to omit logging.SimpleLogging altogether instead of passing it in and not using it.
(Though this does mean you'll have to make logging.SimpleLogging _ in Send())
Signed-off-by: Piotr Pawluk <piotr.pawluk@zendesk.com>
Signed-off-by: Piotr Pawluk <piotr.pawluk@zendesk.com>
|
Looks good to me! |
|
thanks @zendesk-piotrpawluk for the contribution |
what
Adding HTTP webhook implementation to send notifications to any HTTP(S) endpoint.
httpwebhook kind--webhook-http-headersoptional parameter to pass any extra headers with the requestProjectNameto webhook payloadwhy
To send notifications to other systems than just Slack. Feature request: #810
tests
references