If session doesn't exist, don't panic!

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-08-30 18:55:13 -03:00
parent e079517803
commit 4b00a9c0eb

View File

@@ -12,10 +12,15 @@ func DeleteInstance(rw http.ResponseWriter, req *http.Request) {
instanceName := vars["instanceName"] instanceName := vars["instanceName"]
s := core.SessionGet(sessionId) s := core.SessionGet(sessionId)
i := core.InstanceGet(s, instanceName) if s != nil {
err := core.InstanceDelete(s, i) i := core.InstanceGet(s, instanceName)
if err != nil { err := core.InstanceDelete(s, i)
rw.WriteHeader(http.StatusInternalServerError) if err != nil {
rw.WriteHeader(http.StatusInternalServerError)
return
}
} else {
rw.WriteHeader(http.StatusNotFound)
return return
} }
} }