Skip to content

Instantly share code, notes, and snippets.

@rictorres
Created June 10, 2023 09:40
Show Gist options
  • Save rictorres/06c7dd8497c9a62d8a0eebcf7948e962 to your computer and use it in GitHub Desktop.
Save rictorres/06c7dd8497c9a62d8a0eebcf7948e962 to your computer and use it in GitHub Desktop.

Revisions

  1. rictorres created this gist Jun 10, 2023.
    27 changes: 27 additions & 0 deletions lambda.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    // Simplest Lambda URL test

    package main

    import (
    "context"
    "fmt"

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

    func handleRequest(ctx context.Context, request events.LambdaFunctionURLRequest) (events.LambdaFunctionURLResponse, error) {
    fmt.Printf("Processing request data for request %s.\n", request.RequestContext.RequestID)
    fmt.Printf("Body size = %d.\n", len(request.Body))

    fmt.Println("Headers:")
    for key, value := range request.Headers {
    fmt.Printf(" %s: %s\n", key, value)
    }

    return events.LambdaFunctionURLResponse{StatusCode: 204}, nil
    }

    func main() {
    lambda.Start(handleRequest)
    }