Move max instnace check to playground config

This commit is contained in:
Marcos Lilljedahl
2018-02-24 12:31:30 -03:00
parent 0414f4933c
commit b390cfa4e5
3 changed files with 15 additions and 10 deletions

View File

@@ -38,6 +38,20 @@ func NewInstance(rw http.ResponseWriter, req *http.Request) {
return
}
instances, err := core.InstanceFindBySession(s)
if err != nil {
log.Println(err)
rw.WriteHeader(http.StatusInternalServerError)
return
}
if playground.InstancesMax > 0 && len(instances) > playground.MaxInstances {
log.Println(err)
rw.WriteHeader(http.StatusConflict)
return
}
i, err := core.InstanceNew(s, body)
if err != nil {
if pwd.SessionComplete(err) {