added commit

This commit is contained in:
Victor Vieux
2013-04-24 16:06:30 +02:00
parent 1e357c6969
commit 79512b2a80
3 changed files with 53 additions and 11 deletions
+26
View File
@@ -347,6 +347,32 @@ func ListenAndServe(addr string, rtime *Runtime) error {
}
})
r.Path("/containers/{name:.*}/commit").Methods("POST").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log.Println(r.Method, r.RequestURI)
if err := r.ParseForm(); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
vars := mux.Vars(r)
name := vars["name"]
repo := r.Form.Get("repo")
tag := r.Form.Get("tag")
comment := r.Form.Get("comment")
img, err := rtime.Commit(name, repo, tag, comment)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
b, err := json.Marshal(ApiCommit{img.ShortId()})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
} else {
w.Write(b)
}
})
r.Path("/images/{name:.*}/tag").Methods("POST").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log.Println(r.Method, r.RequestURI)
if err := r.ParseForm(); err != nil {