How to get the HTTP method in AWS Lambda? : <p>In an AWS Lambda code, how can I get the HTTP method (e.g. GET, POST...) of an HTTP request coming from the AWS Gateway API? </p>

<p>I understand from the <a href="http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html" rel="noreferrer">documentation</a> that <strong>context.httpMethod</strong> is the solution for that. </p>

<p>However, I cannot manage to make it work. </p>

<p>For instance,  when I try to add the following 3 lines:</p>

<pre><code>    if (context.httpMethod) {
            console.log('HTTP method:', context.httpMethod)
    }
</code></pre>

<p>into the AWS sample code of the "microservice-http-endpoint" blueprint as follows:</p>

<pre><code>exports.handler = function(event, context) {

    if (context.httpMethod) {
        console.log('HTTP method:', context.httpMethod)
    }

    console.log('Received event:', JSON.stringify(event, null, 2));

    // For clarity, I have removed the remaining part of the sample
    // provided by AWS, which works well, for instance when triggered 
    // with Postman through the API Gateway as an intermediary.
};
</code></pre>

<p>I never have anything in the log because <strong>httpMethod is always empty</strong>. </p>
