Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable routing via /functions/ endpoint
- Loading branch information
Showing
6 changed files
with
85 additions
and
19 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#!/bin/sh | ||
echo Building catservice:latest | ||
|
||
docker build -t catservice . | ||
echo Building server:latest | ||
|
||
docker build -t server . |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM golang:1.7.3 | ||
RUN mkdir -p /go/src/app | ||
COPY handler.go /go/src/app | ||
WORKDIR /go/src/app | ||
RUN go get -d -v | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . | ||
|
||
COPY fwatchdog /usr/bin/ | ||
|
||
ENV fprocess="/go/src/app/app" | ||
CMD ["fwatchdog"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
WebhookStash | ||
============ | ||
|
||
Example serverless function shows how to stash way contents of webhooks called via API gateway. | ||
|
||
Each file is saved with the UNIX timestamp in nano seconds plus an extension of .txt | ||
|
||
Example: | ||
|
||
``` | ||
# curl -X POST -v -d @$HOME/.ssh/id_rsa.pub localhost:8080/function/webhookstash | ||
``` | ||
|
||
Then if you find the replica you can check the disk: | ||
|
||
``` | ||
# docker exec webhookstash.1.z054csrh70tgk9s5k4bb8uefq find | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
func main() { | ||
input, _ := ioutil.ReadAll(os.Stdin) | ||
fmt.Println("Stashing request") | ||
now := time.Now() | ||
stamp := strconv.FormatInt(now.UnixNano(), 10) | ||
|
||
ioutil.WriteFile(stamp+".txt", input, 0644) | ||
} |