func Test_Process(t *testing.T) { b := []byte(`{"body": [ { "event":"unsubscribe" }, { "event":"deferred" }]}`) var params proxy.Params json.Unmarshal(b, ¶ms) err := proxy.Process(b, params.Body) assert.NoError(t, err, "request should be proxied") }
func main() { apex.HandleFunc(func(event json.RawMessage, ctx *apex.Context) (interface{}, error) { log.Println(string(event)) var params proxy.Params if err := json.Unmarshal(event, ¶ms); err != nil { return nil, err } if err := proxy.Process(event, params.Body); err != nil { return nil, err } if err := s3.Upload(event, params.Account); err != nil { return nil, err } return nil, errors.New("Upload to S3 - OK. Proxy Request - OK") }) }