Documentation ¶
Overview ¶
Example ¶
package main import ( "context" "fmt" "net/http/httptest" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/service/lambda" "github.com/mashiike/lambdastub" ) func main() { handler := func() (interface{}, error) { return "hello world!?", nil } mux, err := lambdastub.New( lambdastub.WithInvokeEndpoint(map[string]interface{}{ "HelloWorldFunction": handler, }), ) if err != nil { fmt.Println("error: ", err) } server := httptest.NewServer(mux) defer server.Close() client := lambda.New( lambda.Options{ Credentials: credentials.NewStaticCredentialsProvider("ACCESS_KEY_ID", "SECRET_KEY", "TOKEN"), EndpointResolver: lambda.EndpointResolverFunc(func(region string, options lambda.EndpointResolverOptions) (aws.Endpoint, error) { return aws.Endpoint{ URL: server.URL, PartitionID: "aws", SigningRegion: "us-west-1", HostnameImmutable: true, }, nil }), }, ) output, err := client.Invoke(context.Background(), &lambda.InvokeInput{ FunctionName: aws.String("HelloWorldFunction"), Payload: nil, }) if err != nil { fmt.Println("error: ", err) } fmt.Println(string(output.Payload)) }
Output: "hello world!?"
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithInvokeEndpoint ¶
func WithInvokeEndpoint(handlerFuncByFunctionName map[string]interface{}) func(*StubOptions) error
Types ¶
type InvokeEndpoint ¶
type InvokeEndpoint struct {
// contains filtered or unexported fields
}
https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html
func (*InvokeEndpoint) ServeHTTP ¶
func (e *InvokeEndpoint) ServeHTTP(w http.ResponseWriter, r *http.Request)
type StubOptions ¶
Click to show internal directories.
Click to hide internal directories.