Created
May 4, 2022 13:55
-
-
Save dsandor/0ccdb18c775755b5a966477a1af4aeb6 to your computer and use it in GitHub Desktop.
Websocket Lambda Route Handler in Golang
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
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