Skip to content

Instantly share code, notes, and snippets.

// AWS Lambda go style
func helloWorld() string {
returnHello World
}
lambdaFn := sparta.HandleAWSLambda(“Hello World”,
helloWorld,
sparta.IAMRoleDefinition{})
// AWS Lambda Go style
func helloWorld() (string, error) {
return "Hello World", nil
}
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
@mweagle
mweagle / oldmodel.go
Created January 22, 2018 02:13
sparta_old_model
// filename: cmd/main.go
package main
import (
io
net/http
os
spartagithub.com/mweagle/Sparta
)
// http.HandlerFunc style
func helloWorld(w http.ResponseWriter, r *http.Request) {
loggerVal, loggerValOk := r.Context().Value(sparta.ContextKeyLogger).(*logrus.Logger)
func helloSpartaWorld(w http.ResponseWriter, r *http.Request) {
...
}
// 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)
}
func init() {
sparta.RegisterCodePipelineEnvironment("test", map[string]string{
"MESSAGE": "Hello Test!",
})
sparta.RegisterCodePipelineEnvironment("production", map[string]string{
"MESSAGE": "Hello Production!",
})
}
@mweagle
mweagle / include.go
Created May 3, 2017 02:08
import header
import (
spartaCGOgithub.com/mweagle/Sparta/cgo
)