From d245d25ada06c41786097853594214c62bb9a802 Mon Sep 17 00:00:00 2001 From: tom doron Date: Thu, 6 Aug 2020 14:32:22 -0700 Subject: [PATCH] better error message when invoking local lambda server with incorrect http method motivation: nicer error messages changes: return 405 when using wrong http method on the lambda invocatoin endpoint (local debug server) --- Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift b/Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift index 3261b6dd..48cea94e 100644 --- a/Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift +++ b/Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift @@ -149,6 +149,10 @@ private enum LocalLambda { Self.invocations.append(invocation) } + // lambda invocation using the wrong http method + case (_, let url) where url.hasSuffix(self.invocationEndpoint): + self.writeResponse(context: context, status: .methodNotAllowed) + // /next endpoint is called by the lambda polling for work case (.GET, let url) where url.hasSuffix(Consts.getNextInvocationURLSuffix): // check if our server is in the correct state