Skip to content
Snippets Groups Projects
Commit 064279bb authored by Francé Wilke's avatar Francé Wilke
Browse files

Cater for body exclusion in LogRequestInfo

parent f31d5d3c
No related branches found
No related tags found
No related merge requests found
......@@ -219,11 +219,14 @@ func LogShipmentID(id int64) {
}, "Current-shipment-ID")
}
func LogRequestInfo(req events.APIGatewayProxyRequest, extraFields ...map[string]interface{}) {
func LogRequestInfo(req events.APIGatewayProxyRequest, shouldExcludeBody bool, extraFields map[string]interface{}) {
fields := map[string]interface{}{
"path": req.Path,
"method": req.HTTPMethod,
"body": req.Body,
}
if !shouldExcludeBody {
fields["body"] = req.Body
}
if req.QueryStringParameters != nil {
......@@ -234,13 +237,11 @@ func LogRequestInfo(req events.APIGatewayProxyRequest, extraFields ...map[string
fields["client_version"] = req.Headers["client-version"]
}
if extraFields != nil {
for i := range extraFields {
for k, v := range extraFields[i] {
for k, v := range extraFields {
if k != "" {
fields[k] = v
}
}
}
InfoWithFields(fields, "Req")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment