Skip to content

Commit

Permalink
AWS Lambda: Fix validation issues
Browse files Browse the repository at this point in the history
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
  • Loading branch information
bramwelt committed May 2, 2024
1 parent f9b6f51 commit 6fdf34a
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions pkg/middlewares/awslambda/aws_lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (a *awsLambda) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
// If sending data through cURL on the commandline and
// the content-type header is missed, orr for
// applications that aren't explicitly setting Content-Type,
// override to 'application/json' if the body looks like JSON
// override to 'application/json' if the body looks like JSON.
if isJSON(reqBody) {
req.Header.Set("Content-Type", "application/json")
}
Expand Down Expand Up @@ -360,19 +360,6 @@ func headersToMap(h http.Header) map[string]string {
return values
}

func headersToMultiMap(h http.Header) map[string][]string {
values := map[string][]string{}
for name, headers := range h {
if len(headers) < 2 {
continue
}

values[name] = headers
}

return values
}

func valueToString(f interface{}) (string, bool) {
var v string
typeof := reflect.TypeOf(f)
Expand Down Expand Up @@ -459,7 +446,7 @@ func valuesToMultiMap(i url.Values) map[string][]string {
return values
}

// Check if a string looks like JSON
// Check if a string looks like JSON.
func isJSON(s string) bool {
var js interface{}
return json.Unmarshal([]byte(s), &js) == nil
Expand Down

0 comments on commit 6fdf34a

Please sign in to comment.