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:
Alex Ellis (OpenFaaS Ltd)
2023-01-17 21:55:48 +00:00
parent 8e1c34e222
commit c26ec5221e
188 changed files with 22639 additions and 3717 deletions

View File

@ -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
}