Posts

Showing posts from 2023

Uploading and Running Lambda function in AWS

Main.go package main import ( "fmt" "encoding/json" "log" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" ) func main () { lambda. Start (handler) } func handler (request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error ) { var person Person //json request body se nikaal ke person var me rakh denge err := json. Unmarshal ([] byte (request.Body), &person) if err != nil { return events.APIGatewayProxyResponse{}, err } //ab person se firstname aur lastname nikaal ke msg bana lenge msg := fmt. Sprintf ( "Hello %v %v " , *person.FirstName, *person.LastName) responseBody := ResponseBody{ Message: &msg, } jbytes , err := json. Marshal (responseBody) if err != nil { return events.APIGatewayProxyResponse{}, err } log. Println ( "hello world Nihal" ) ...