// Parse verifies and parses the events specified and returns the payload object or an error
Parse verifies and parses the events specified and returns the payload object or an error
// Parse verifies and parses the events specified and returns the payload object or an error
func Parse(r *http.Request) (interface{}, error) {
	defer func() {
		_, _ = io.Copy(ioutil.Discard, r.Body)
		_ = r.Body.Close()
	}()
	if r.Method != http.MethodPost {
		return nil, ErrInvalidHTTPMethod
	}
	payload, err := ioutil.ReadAll(r.Body)
	if err != nil || len(payload) == 0 {
		return nil, ErrParsingPayload
	}
	var pl CallbackPayload
	err = json.Unmarshal([]byte(payload), &pl)
	if err != nil {
		return nil, ErrParsingPayload
	}
	return pl, err
}
func Parse ( r * http . Request ) ( interface { } , error ) { defer func ( ) { _ , _ = io . Copy ( ioutil . Discard , r . Body ) _ = r . Body . Close ( ) } ( ) if r . Method != http . MethodPost { return nil , ErrInvalidHTTPMethod } payload , err := ioutil . ReadAll ( r . Body ) if err != nil || len ( payload ) == 0 { return nil , ErrParsingPayload } var pl CallbackPayload err = json . Unmarshal ( [ ] byte ( payload ) , & pl ) if err != nil { return nil , ErrParsingPayload } return pl , err }
Parse verifies and parses the events specified and returns the payload object or an error
Parse verifies and parses the events specified and returns the payload object or an error