go.stripe
go.stripe copied to clipboard
Implement HandlerFunc for Events
Implement an http.HandlerFunc so that a developer can easily handle Stripe Events.
i'm thinking something like this
type EventCallback func(Event);
func HandleEvent(callback EventCallback) {
return func(req *http.Request, resp http.Response) {
// parse the event in the incoming request
event, err := json.Unmarshall(...)
// return a 202 so that stripe knows we go it
w.WriteHeader(http.StatusOK)
// invoke EventCallback function
go callback(event)
}
}