Skip to content

Instantly share code, notes, and snippets.

@dsandor
Created May 4, 2022 13:55
Show Gist options
  • Save dsandor/0ccdb18c775755b5a966477a1af4aeb6 to your computer and use it in GitHub Desktop.
Save dsandor/0ccdb18c775755b5a966477a1af4aeb6 to your computer and use it in GitHub Desktop.
Websocket Lambda Route Handler in Golang
type DefaultResponse struct {
StatusCode int `json:"statusCode"`
Body string `json:"body"`
IsBase64Encoded bool `json:"isBase64Encoded"`
Headers struct {
ContentType string `json:"content-type"`
} `json:"headers"`
}
func (d *dependencies) list(ctx context.Context, websocketEvent events.APIGatewayWebsocketProxyRequest) (DefaultResponse, error) {
fmt.Println("Default route handler hit.")
fmt.Printf("%+v\n", websocketEvent)
response := &DefaultResponse{
StatusCode: 200,
Body: "Hello, from default route.",
IsBase64Encoded: false,
Headers: struct {
ContentType string `json:"content-type"`
}(struct{ ContentType string }{
ContentType: "application/json",
})}
return *response, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment