Skip to content

Instantly share code, notes, and snippets.

View sgarcez's full-sized avatar
🌀
.

Sergio Garcez sgarcez

🌀
.
View GitHub Profile
@sgarcez
sgarcez / README.md
Last active January 7, 2022 10:52
Patron Compression Middlware Content-Length Issue

Patron Compression Middlware Content-Length Issue

Run test server

$ go run main.go

Before fix

Keybase proof

I hereby claim:

  • I am sgarcez on github.
  • I am sgarcez (https://keybase.io/sgarcez) on keybase.
  • I have a public key ASBIW3PYnxZsuL64I77wEN9eV9_4wnpOo7pquvJXPIKY6Ao

To claim this, I am signing this object:

res, err := internal.SamInvoke("../../cloudformation.yaml", "AddTask", `{"note": "foo"}`)
{
"code": "TASK_NOT_FOUND",
"public_message": "Task not found",
"private_message": "unknown task: foo-bar"
}
x-amazon-apigateway-gateway-responses:
DEFAULT_4XX:
defaultResponse: false
responseParameters:
gatewayresponse.header.Content-Type: "'application/json'"
responseTemplates:
application/json: |
{
"code": "$context.error.responseType",
"message": $context.error.messageString
x-amazon-apigateway-integration:
#...
responses:
".*\\\"code\\\":\\\"[A-Z_]+_NOT_FOUND\\\".*":
statusCode: "404"
responseParameters:
method.response.header.Content-Type : "'application/json'"
responseTemplates:
application/json: |
#set ($errorMessageObj = $util.parseJson($input.path('$.errorMessage')))
{
"errorMessage": "{\"code\":\"TASK_NOT_FOUND\",\"public_message\":\"Task not found\",\"private_message\":\"unknown task: foo-bar\"}",
"errorType": "lambdaError"
}
type lambdaError struct {
code string
message string
origErr error
}
func (e lambdaError) Error() string {
b, err := json.Marshal(e)
if err != nil {
{
"errorMessage": "Uh-oh. Something went wrong",
"errorType": "errorString"
}
func handler(event json.RawMessage) error {
return errors.New(“Uh-oh. Something went wrong”)
}