mux-go
mux-go copied to clipboard
Typed models for working with webhooks
Not a huge deal but it would be nice if this package included typed models for easier webhook processing.
For example, I'd like to process the payload data in a video.live_stream.created
webhook event however there are incompatible differences with the near-identical muxgo.LiveStream
struct.
var payload struct {
Type string `json:"type"`
Data muxgo.LiveStream `json:"data"`
}
if err := resty.Unmarshalc(resty.New(), "application/json", body, &payload); err != nil {
panic("json: cannot unmarshal number into Go struct field LiveStream.data.created_at of type string")
}
In this particular case, the webhook uses integer dates whereas the API model uses RFC3339 dates.
Hey @NathanBaulch, thanks for the feedback here, really appreciate it. We're aware of this issue and that it limits the usability of the SDK for receiving webhooks.
I don't have a timeline on addressing this as resolving it would require a breaking change to our API, or a lot of code duplication, but we are aware of this and working towards a solution.
Thanks.