Initial pop-up for new function.

This commit is contained in:
Alex
2017-02-23 08:21:33 +00:00
committed by Alex Ellis
parent edc2c4b29e
commit 98c9ef67f4
9 changed files with 105 additions and 33 deletions

View File

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