Skip to content

Commit 3411110

Browse files
committed
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) <[email protected]>
1 parent 82a5165 commit 3411110

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

template/golang-http/function/handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"net/http"
66

7-
"github.com/openfaas-incubator/go-function-sdk"
7+
handler "github.com/openfaas-incubator/go-function-sdk"
88
)
99

1010
// Handle a function invocation

template/golang-http/go.mod

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ go 1.13
44

55
replace handler/function => ./function
66

7-
require github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921
7+
// require github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921
8+
9+
require github.com/openfaas-incubator/go-function-sdk v0.0.0-20200405082418-b31e65bf8a33

template/golang-http/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 h1:IGP0tlTdv6r/zy3Kw61EhiXao61krCUs5KRHWSzCdxM=
2-
github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921/go.mod h1:F37Kp+hwdHP+o3UKjkGzikQg4weKiMvcegT9vCQjvjE=
1+
github.com/openfaas-incubator/go-function-sdk v0.0.0-20200405082418-b31e65bf8a33 h1:KhbcrtXR+IO7IWF08RzKpgMudBhEeRRqNmRurE1iph4=
2+
github.com/openfaas-incubator/go-function-sdk v0.0.0-20200405082418-b31e65bf8a33/go.mod h1:F37Kp+hwdHP+o3UKjkGzikQg4weKiMvcegT9vCQjvjE=

template/golang-http/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func makeRequestHandler() func(http.ResponseWriter, *http.Request) {
9797
Method: r.Method,
9898
QueryString: r.URL.RawQuery,
9999
}
100+
req.WithContext(r.Context())
100101

101102
result, resultErr := function.Handle(req)
102103

0 commit comments

Comments
 (0)