WIP
This commit is contained in:
@@ -6,27 +6,25 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/play-with-docker/play-with-docker/services"
|
||||
"github.com/play-with-docker/play-with-docker/pwd"
|
||||
)
|
||||
|
||||
func NewInstance(rw http.ResponseWriter, req *http.Request) {
|
||||
vars := mux.Vars(req)
|
||||
sessionId := vars["sessionId"]
|
||||
|
||||
body := services.InstanceConfig{}
|
||||
body := pwd.InstanceConfig{}
|
||||
|
||||
json.NewDecoder(req.Body).Decode(&body)
|
||||
|
||||
s := services.GetSession(sessionId)
|
||||
s := core.SessionGet(sessionId)
|
||||
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
if len(s.Instances) >= 5 {
|
||||
rw.WriteHeader(http.StatusConflict)
|
||||
return
|
||||
}
|
||||
|
||||
i, err := services.NewInstance(s, body)
|
||||
i, err := core.InstanceNew(s, body)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
rw.WriteHeader(http.StatusInternalServerError)
|
||||
|
||||
Reference in New Issue
Block a user