mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 12:06:37 +00:00
Updates for NATS Streaming support
NATS Streaming is deprecated and will be removed from OpenFaaS CE in a future release for security reasons. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
@ -6,6 +6,7 @@ package handlers
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@ -21,15 +22,16 @@ import (
|
||||
// MakeQueuedProxy accepts work onto a queue
|
||||
func MakeQueuedProxy(metrics metrics.MetricOptions, queuer ftypes.RequestQueuer, pathTransformer middleware.URLPathTransformer, defaultNS string, functionQuery scaling.FunctionQuery) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var body []byte
|
||||
if r.Body != nil {
|
||||
defer r.Body.Close()
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
var err error
|
||||
body, err = ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
callbackURL, err := getCallbackURLHeader(r.Header)
|
||||
@ -53,8 +55,9 @@ func MakeQueuedProxy(metrics metrics.MetricOptions, queuer ftypes.RequestQueuer,
|
||||
}
|
||||
|
||||
if err = queuer.Queue(req); err != nil {
|
||||
fmt.Printf("Queue error: %v\n", err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
log.Printf("Error queuing request: %v", err)
|
||||
http.Error(w, fmt.Sprintf("Error queuing request: %s", err.Error()),
|
||||
http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user