'Why isn't my element of Lambda Handler initialized?

if i send http request to my server using Postman

The element of the handler function (req) is not initialized.

Like this

{
  "resource": "",
  "path": "",
  "httpMethod": "",
  "headers": null,
  "multiValueHeaders": null,
  "queryStringParameters": null,
  "multiValueQueryStringParameters": null,
  "pathParameters": null,
  "stageVariables": null,
  "requestContext": {
    "accountId": "",

    omitted...

  },
  "body": ""
}

this is my main.go file

package main

import (
"os"

"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
)

func main() {
   region := os.Getenv("AWS_REGION")

   _, err := session.NewSession(&aws.Config{
       Region: aws.String(region),
   })
   if err != nil {
       return
   }

   lambda.Start(handler)
}

func handler(req events.APIGatewayProxyRequest) 
   (*events.APIGatewayProxyResponse, error) {
   switch req.HTTPMethod {
   case "GET":
       return handlers.GetToken(req)
   default:
       return handlers.UnhandleMethod()
   } 
}

My OS is windows, so I deployed it as shown in the link. https://github.com/aws/aws-lambda-go

Please tell me what's wrong. any help would be very Appreciated :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source