mirror of
https://github.com/openfaas/faas.git
synced 2025-06-24 15:53:26 +00:00
Sync async_nats work with master
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
23
gateway/handlers/asyncreport.go
Normal file
23
gateway/handlers/asyncreport.go
Normal file
@ -0,0 +1,23 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/alexellis/faas/gateway/metrics"
|
||||
"github.com/alexellis/faas/gateway/requests"
|
||||
)
|
||||
|
||||
// MakeAsyncReport makes a handler for asynchronous invocations to report back into.
|
||||
func MakeAsyncReport(metrics metrics.MetricOptions) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
|
||||
report := requests.AsyncReport{}
|
||||
bytesOut, _ := ioutil.ReadAll(r.Body)
|
||||
json.Unmarshal(bytesOut, &report)
|
||||
|
||||
trackInvocation(report.FunctionName, metrics, report.StatusCode)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user