go.stripe icon indicating copy to clipboard operation
go.stripe copied to clipboard

Implement HandlerFunc for Events

Open bradrydzewski opened this issue 12 years ago • 0 comments

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)
    }
}

bradrydzewski avatar Jun 06 '12 00:06 bradrydzewski