Skip to content

Commit 6a4dc07

Browse files
committed
Original function name in callback meta-data
Adds original function name in callback meta-data `X-Function-Name` Resolves #82 Signed-off-by: Edward Wilde <ewilde@gmail.com>
1 parent f67fee0 commit 6a4dc07

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ func main() {
111111
functionResult,
112112
req.CallbackURL.String(),
113113
xCallID,
114-
status)
114+
status,
115+
req.Function)
115116

116117
if resultErr != nil {
117118
log.Printf("Posted callback to: %s - status %d, error: %s\n", req.CallbackURL.String(), http.StatusServiceUnavailable, resultErr.Error())
@@ -160,7 +161,8 @@ func main() {
160161
functionResult,
161162
req.CallbackURL.String(),
162163
xCallID,
163-
res.StatusCode)
164+
res.StatusCode,
165+
req.Function)
164166

165167
if resultErr != nil {
166168
log.Printf("Error posting to callback-url: %s\n", resultErr)
@@ -252,7 +254,8 @@ func makeClient() http.Client {
252254
return proxyClient
253255
}
254256

255-
func postResult(client *http.Client, functionRes *http.Response, result []byte, callbackURL string, xCallID string, statusCode int) (int, error) {
257+
func postResult(client *http.Client, functionRes *http.Response, result []byte, callbackURL string, xCallID string,
258+
statusCode int, functionName string) (int, error) {
256259
var reader io.Reader
257260

258261
if result != nil {
@@ -270,6 +273,7 @@ func postResult(client *http.Client, functionRes *http.Response, result []byte,
270273
}
271274

272275
request.Header.Set("X-Function-Status", fmt.Sprintf("%d", statusCode))
276+
request.Header.Set("X-Function-Name", functionName)
273277

274278
if len(xCallID) > 0 {
275279
request.Header.Set("X-Call-Id", xCallID)

0 commit comments

Comments
 (0)