Created
October 6, 2017 13:06
-
-
Save mlafeldt/abb7473814e9426e8cc1cd7f2b7c7ac2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"log" | |
"github.com/apex/go-apex" | |
"github.com/apex/go-apex/sns" | |
) | |
type message struct { | |
Hello string `json:"hello"` | |
} | |
func main() { | |
apex.HandleFunc(func(event json.RawMessage, ctx *apex.Context) (interface{}, error) { | |
var snsEvent sns.Event | |
if err := json.Unmarshal(event, &snsEvent); err != nil { | |
return nil, err | |
} | |
log.Printf("%+v\n", string(event)) | |
log.Printf("%+v\n", snsEvent.Records[0].SNS.Message) | |
return snsEvent, nil | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
there's a service-specific handler for each as well https://github.com/apex/go-apex/blob/master/sns/sns.go#L61, does the json part for you