Last active
April 11, 2016 16:40
-
-
Save mweagle/7cac46d0bc03018d1eccaaf802c19d21 to your computer and use it in GitHub Desktop.
Hello world for Medium
This file contains 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
// File: application.go | |
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"net/http" | |
"github.com/Sirupsen/logrus" | |
sparta "github.com/mweagle/Sparta" | |
) | |
//////////////////////////////////////////////////////////////////////////////// | |
// Hello world event handler | |
// | |
func helloWorld(event *json.RawMessage, | |
context *sparta.LambdaContext, | |
w http.ResponseWriter, | |
logger *logrus.Logger) { | |
logger.Info("Hello World: ", string(*event)) | |
fmt.Fprint(w, string(*event)) | |
} | |
//////////////////////////////////////////////////////////////////////////////// | |
// Main | |
func main() { | |
var lambdaFunctions []*sparta.LambdaAWSInfo | |
lambdaFn := sparta.NewLambda(sparta.IAMRoleDefinition{}, helloWorld, nil) | |
lambdaFunctions = append(lambdaFunctions, lambdaFn) | |
// Deploy it | |
sparta.Main("SpartaHelloWorld", | |
"Simple Sparta application that creates a single AWS Lambda function", | |
lambdaFunctions, | |
nil, | |
nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment