mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 01:57:32 +08:00
25 lines
503 B
Go
25 lines
503 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/franela/play-with-docker/services"
|
|
"github.com/gorilla/mux"
|
|
)
|
|
|
|
func DeleteInstance(rw http.ResponseWriter, req *http.Request) {
|
|
vars := mux.Vars(req)
|
|
sessionId := vars["sessionId"]
|
|
instanceName := vars["instanceName"]
|
|
|
|
s := services.GetSession(sessionId)
|
|
s.Lock()
|
|
defer s.Unlock()
|
|
i := services.GetInstance(s, instanceName)
|
|
err := services.DeleteInstance(s, i)
|
|
if err != nil {
|
|
rw.WriteHeader(http.StatusInternalServerError)
|
|
return
|
|
}
|
|
}
|