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 AWS λ function | |
| func helloWorld(event *json.RawMessage, | |
| context *sparta.LambdaContext, | |
| w http.ResponseWriter, | |
| logger *logrus.Logger) { | |
| helloWorldCounterMetric.Inc(1) | |
| fmt.Fprint(w, "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
| package main | |
| import ( | |
| "fmt" | |
| "os" | |
| sparta "github.com/mweagle/Sparta" | |
| "github.com/mweagle/SpartaPython" | |
| "github.com/mweagle/Sparta/cgo" |
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 | |
| // #include <stdio.h> | |
| // #include <stdlib.h> | |
| // #include <string.h> | |
| // #include <stdio.h> | |
| import "C" | |
| import "github.com/aws/aws-sdk-go/aws/credentials" | |
| import ( |
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
| 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) |
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
| // 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, |
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” | |
| ) |
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
| // 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 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
| loggerVal, loggerValOk := r.Context().Value(sparta.ContextKeyLogger).(*logrus.Logger) |