Skip to content

Instantly share code, notes, and snippets.

Matt Weagle mweagle

Block or report user

Report or block mweagle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View new_style.go
// AWS Lambda Go style
func helloWorld() (string, error) {
return "Hello World", nil
}
View sparta_old_model.log
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 Jan 22, 2018
sparta_old_model
View oldmodel.go
// 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) {
View lambdaContext.go
loggerVal, loggerValOk := r.Context().Value(sparta.ContextKeyLogger).(*logrus.Logger)
View newLambda.go
func helloSpartaWorld(w http.ResponseWriter, r *http.Request) {
...
}
View spartalambda.go
// 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)
}
View environments.go
func init() {
sparta.RegisterCodePipelineEnvironment("test", map[string]string{
"MESSAGE": "Hello Test!",
})
sparta.RegisterCodePipelineEnvironment("production", map[string]string{
"MESSAGE": "Hello Production!",
})
}
View include.go
import (
spartaCGOgithub.com/mweagle/Sparta/cgo
)
View mock_http.go
// Create an http.Request object with this data...
spartaResp := newSpartaMockHTTPResponse()
spartaReq := &http.Request{
Method: "POST",
URL: &url.URL{
Scheme: "http",
Path: fmt.Sprintf("/%s", functionName),
},
Proto: "HTTP/1.1",
ProtoMajor: 1,
@mweagle
mweagle / shim.py
Created May 3, 2017
Python core shim
View shim.py
bytesWritten = lib.Lambda(funcName.encode(‘utf-8’),
json.dumps(request).encode(‘utf-8’),
credentials.access_key.encode(‘utf-8’),
credentials.secret_key.encode(‘utf-8’),
credentials.token.encode(‘utf-8’),
byref(exitCode),
response_content_type_buffer,
MAX_RESPONSE_CONTENT_TYPE_SIZE-1,
response_buffer,
MAX_RESPONSE_SIZE-1)
You can’t perform that action at this time.