コード例 #1
0
func Test_Process(t *testing.T) {
	b := []byte(`{"body": [
       {
          "event":"unsubscribe"
       },
       {
          "event":"deferred"
       }]}`)
	var params proxy.Params
	json.Unmarshal(b, &params)
	err := proxy.Process(b, params.Body)
	assert.NoError(t, err, "request should be proxied")
}
コード例 #2
0
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, &params); 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")
	})

}