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
// AWS Lambda go style | |
func helloWorld() string { | |
return “Hello World” | |
} |
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
lambdaFn := sparta.HandleAWSLambda(“Hello World”, | |
helloWorld, | |
sparta.IAMRoleDefinition{}) |
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
// AWS Lambda Go style | |
func helloWorld() (string, error) { | |
return "Hello World", nil | |
} |
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
Simple Sparta application that demonstrates core functionality | |
Usage: | |
main [command] | |
Available Commands: | |
delete Delete service | |
describe Describe service | |
execute Execute | |
help Help about any command |
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
// filename: cmd/main.go | |
package main | |
import ( | |
“io” | |
“net/http” | |
“os” | |
sparta “github.com/mweagle/Sparta” | |
) | |
// http.HandlerFunc style | |
func helloWorld(w http.ResponseWriter, r *http.Request) { |
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
loggerVal, loggerValOk := r.Context().Value(sparta.ContextKeyLogger).(*logrus.Logger) |
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
func helloSpartaWorld(w http.ResponseWriter, r *http.Request) { | |
... | |
} |
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
// Standard http.HandlerFunc() that will be run as a lambda function | |
func helloSpartaWorld(w http.ResponseWriter, r *http.Request) { | |
messageText := os.Getenv("MESSAGE") | |
if "" == messageText { | |
messageText = "$MESSAGE not defined" | |
} | |
fmt.Fprint(w, messageText) | |
} |
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
func init() { | |
sparta.RegisterCodePipelineEnvironment("test", map[string]string{ | |
"MESSAGE": "Hello Test!", | |
}) | |
sparta.RegisterCodePipelineEnvironment("production", map[string]string{ | |
"MESSAGE": "Hello Production!", | |
}) | |
} |
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
import ( | |
spartaCGO “github.com/mweagle/Sparta/cgo” | |
) |