mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 03:56:37 +00:00
Initial pop-up for new function.
This commit is contained in:
@ -6,6 +6,8 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/alexellis/faas/gateway/metrics"
|
||||
"github.com/alexellis/faas/gateway/requests"
|
||||
"github.com/docker/docker/api/types"
|
||||
@ -59,3 +61,22 @@ func MakeFunctionReader(metricsOptions metrics.MetricOptions, c *client.Client)
|
||||
w.Write(functionBytes)
|
||||
}
|
||||
}
|
||||
|
||||
// MakeNewFunctionHandler creates a new function (service) inside the swarm network.
|
||||
func MakeNewFunctionHandler(metricsOptions metrics.MetricOptions, c *client.Client) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
body, _ := ioutil.ReadAll(r.Body)
|
||||
defer r.Body.Close()
|
||||
|
||||
request := requests.CreateFunctionRequest{}
|
||||
err := json.Unmarshal(body, &request)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(request)
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user