From ec3fd65b2392377c4fc762a82ad527514dcf4fe9 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Sun, 5 Apr 2020 09:31:28 +0100 Subject: [PATCH 1/2] Propagate Context to the handler.Request This change makes the Context available for use or cancellation within the handler. Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- template/golang-http/function/handler.go | 2 +- template/golang-http/go.mod | 4 +++- template/golang-http/go.sum | 4 ++-- template/golang-http/main.go | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/template/golang-http/function/handler.go b/template/golang-http/function/handler.go index 9e212e7..d201cfd 100644 --- a/template/golang-http/function/handler.go +++ b/template/golang-http/function/handler.go @@ -4,7 +4,7 @@ import ( "fmt" "net/http" - "github.com/openfaas-incubator/go-function-sdk" + handler "github.com/openfaas-incubator/go-function-sdk" ) // Handle a function invocation diff --git a/template/golang-http/go.mod b/template/golang-http/go.mod index f682c81..24f012b 100644 --- a/template/golang-http/go.mod +++ b/template/golang-http/go.mod @@ -4,4 +4,6 @@ go 1.13 replace handler/function => ./function -require github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 +// require github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 + +require github.com/openfaas-incubator/go-function-sdk v0.0.0-20200405082418-b31e65bf8a33 diff --git a/template/golang-http/go.sum b/template/golang-http/go.sum index 94e3413..9f41c78 100644 --- a/template/golang-http/go.sum +++ b/template/golang-http/go.sum @@ -1,2 +1,2 @@ -github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 h1:IGP0tlTdv6r/zy3Kw61EhiXao61krCUs5KRHWSzCdxM= -github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921/go.mod h1:F37Kp+hwdHP+o3UKjkGzikQg4weKiMvcegT9vCQjvjE= +github.com/openfaas-incubator/go-function-sdk v0.0.0-20200405082418-b31e65bf8a33 h1:KhbcrtXR+IO7IWF08RzKpgMudBhEeRRqNmRurE1iph4= +github.com/openfaas-incubator/go-function-sdk v0.0.0-20200405082418-b31e65bf8a33/go.mod h1:F37Kp+hwdHP+o3UKjkGzikQg4weKiMvcegT9vCQjvjE= diff --git a/template/golang-http/main.go b/template/golang-http/main.go index 2363a39..7661c40 100644 --- a/template/golang-http/main.go +++ b/template/golang-http/main.go @@ -97,6 +97,7 @@ func makeRequestHandler() func(http.ResponseWriter, *http.Request) { Method: r.Method, QueryString: r.URL.RawQuery, } + req.WithContext(r.Context()) result, resultErr := function.Handle(req) From 4b7ca0a0a316cd0acf5aa23a0d178d3d3bee30d4 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Sun, 5 Apr 2020 09:35:17 +0100 Subject: [PATCH 2/2] Apply Context to armhf template Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- template/golang-http-armhf/go.mod | 2 +- template/golang-http-armhf/go.sum | 4 ++-- template/golang-http-armhf/main.go | 1 + template/golang-http/go.mod | 2 -- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/template/golang-http-armhf/go.mod b/template/golang-http-armhf/go.mod index f682c81..930f39e 100644 --- a/template/golang-http-armhf/go.mod +++ b/template/golang-http-armhf/go.mod @@ -4,4 +4,4 @@ go 1.13 replace handler/function => ./function -require github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 +require github.com/openfaas-incubator/go-function-sdk v0.0.0-20200405082418-b31e65bf8a33 diff --git a/template/golang-http-armhf/go.sum b/template/golang-http-armhf/go.sum index 94e3413..9f41c78 100644 --- a/template/golang-http-armhf/go.sum +++ b/template/golang-http-armhf/go.sum @@ -1,2 +1,2 @@ -github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 h1:IGP0tlTdv6r/zy3Kw61EhiXao61krCUs5KRHWSzCdxM= -github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921/go.mod h1:F37Kp+hwdHP+o3UKjkGzikQg4weKiMvcegT9vCQjvjE= +github.com/openfaas-incubator/go-function-sdk v0.0.0-20200405082418-b31e65bf8a33 h1:KhbcrtXR+IO7IWF08RzKpgMudBhEeRRqNmRurE1iph4= +github.com/openfaas-incubator/go-function-sdk v0.0.0-20200405082418-b31e65bf8a33/go.mod h1:F37Kp+hwdHP+o3UKjkGzikQg4weKiMvcegT9vCQjvjE= diff --git a/template/golang-http-armhf/main.go b/template/golang-http-armhf/main.go index 2363a39..7661c40 100644 --- a/template/golang-http-armhf/main.go +++ b/template/golang-http-armhf/main.go @@ -97,6 +97,7 @@ func makeRequestHandler() func(http.ResponseWriter, *http.Request) { Method: r.Method, QueryString: r.URL.RawQuery, } + req.WithContext(r.Context()) result, resultErr := function.Handle(req) diff --git a/template/golang-http/go.mod b/template/golang-http/go.mod index 24f012b..930f39e 100644 --- a/template/golang-http/go.mod +++ b/template/golang-http/go.mod @@ -4,6 +4,4 @@ go 1.13 replace handler/function => ./function -// require github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 - require github.com/openfaas-incubator/go-function-sdk v0.0.0-20200405082418-b31e65bf8a33