Last active
February 11, 2021 07:56
-
-
Save percybolmer/a7c5090f56c319c036c43500dba3dcfc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
// aws-lambda package has to be imported | |
"github.com/aws/aws-lambda-go/lambda" | |
) | |
// User is a simple struct to accept as input | |
type User struct { | |
Name string `json:"name"` | |
LastName string `json:"lastname"` | |
} | |
// Greetings is the response to a user entering | |
type Greetings struct { | |
Greet string `json:"greet"` | |
} | |
// String implements the stringer interface for user | |
func (u User) String() string { | |
return fmt.Sprintf("Welcome %s %s", u.Name, u.LastName) | |
} | |
// GreetVisitor is a lambda function that will greet a visitor | |
func GreetVisitor(event User) (Greetings, error) { | |
return Greetings{Greet: event.String()}, nil | |
} | |
func main() { | |
// Lambda start is used to handle the function | |
lambda.Start(GreetVisitor) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment