From 6d921cac506196dee972bab7e022137a7042f7dc Mon Sep 17 00:00:00 2001 From: Alex Ellis Date: Sun, 19 Feb 2017 18:26:55 +0000 Subject: [PATCH] Include base64 sample function in stack Document sample functions with comments Allow functions with 0-9 for route regex --- docker-compose.yml | 25 ++++++++++++++++++++++--- gateway/build.sh | 2 +- gateway/server.go | 4 ++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a87d581f..722c5671 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: - "/var/run/docker.sock:/var/run/docker.sock" ports: - 8080:8080 - image: alexellis2/faas-gateway:latest + image: alexellis2/faas-gateway:latest-dev networks: - functions deploy: @@ -53,6 +53,7 @@ services: # Sample functions go here. + # Service label of "function" allows functions to show up in UI on http://gateway:8080/ webhookstash: image: alexellis2/faas-webhookstash:latest @@ -66,6 +67,7 @@ services: no_proxy: "gateway" https_proxy: $https_proxy + # Pass a username as an argument to find how many images user has pushed to Docker Hub. hubstats: image: alexellis2/faas-dockerhubstats:latest labels: @@ -78,6 +80,7 @@ services: no_proxy: "gateway" https_proxy: $https_proxy + # Node.js gives OS info about the node (Host) nodeinfo: image: alexellis2/faas-nodeinfo:latest labels: @@ -90,6 +93,7 @@ services: no_proxy: "gateway" https_proxy: $https_proxy + # Uses `cat` to echo back response, fastest function to execute. echoit: image: alexellis2/faas-alpinefunction:latest labels: @@ -103,6 +107,7 @@ services: no_proxy: "gateway" https_proxy: $https_proxy + # Counts words in request with `wc` utility wordcount: image: alexellis2/faas-alpinefunction:latest labels: @@ -116,6 +121,21 @@ services: no_proxy: "gateway" https_proxy: $https_proxy + # Calculates base64 representation of request body. + base64: + image: alexellis2/faas-alpinefunction:latest + labels: + function: "true" + depends_on: + - gateway + networks: + - functions + environment: + fprocess: "base64" + no_proxy: "gateway" + https_proxy: $https_proxy + + # Converts body in (markdown format) -> (html) markdown: image: alexellis2/faas-markdownrender:latest labels: @@ -128,6 +148,7 @@ services: no_proxy: "gateway" https_proxy: $https_proxy + # Example of Alexa SDK skill, set skill to invoke HTTPs endpoint in Amazon Alexa Skills page. alexacolorchange: labels: function: "true" @@ -140,8 +161,6 @@ services: no_proxy: "gateway" https_proxy: $https_proxy - - networks: functions: driver: overlay diff --git a/gateway/build.sh b/gateway/build.sh index c000c144..3578ff14 100755 --- a/gateway/build.sh +++ b/gateway/build.sh @@ -10,4 +10,4 @@ docker rm -f gateway_extract echo Building alexellis2/faas-gateway:latest -docker build --no-cache -t alexellis2/faas-gateway:latest-dev4 . +docker build --no-cache -t alexellis2/faas-gateway:latest-dev . diff --git a/gateway/server.go b/gateway/server.go index de6494c3..5dc96d7c 100644 --- a/gateway/server.go +++ b/gateway/server.go @@ -36,8 +36,8 @@ func main() { // r.StrictSlash(false) functionHandler := faashandlers.MakeProxy(metricsOptions, true, dockerClient, &logger) - r.HandleFunc("/function/{name:[a-zA-Z_]+}", functionHandler) - r.HandleFunc("/function/{name:[a-zA-Z_]+}/", functionHandler) + r.HandleFunc("/function/{name:[a-zA-Z_0-9]+}", functionHandler) + r.HandleFunc("/function/{name:[a-zA-Z_0-9]+}/", functionHandler) r.HandleFunc("/system/alert", faashandlers.MakeAlertHandler(dockerClient)) r.HandleFunc("/system/functions", faashandlers.MakeFunctionReader(metricsOptions, dockerClient)).Methods("GET")