forked from vmware-archive/atc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rename.go
37 lines (31 loc) · 897 Bytes
/
rename.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package pipelineserver
import (
"encoding/json"
"io/ioutil"
"net/http"
"github.com/concourse/atc/db"
)
func (s *Server) RenamePipeline(pipelineDB db.PipelineDB) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
data, err := ioutil.ReadAll(r.Body)
if err != nil {
s.logger.Error("call-to-update-pipeline-name-copy-failed", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
var value struct{ Name string }
err = json.Unmarshal(data, &value)
if err != nil {
s.logger.Error("call-to-update-pipeline-name-unmarshal-failed", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
err = pipelineDB.UpdateName(value.Name)
if err != nil {
s.logger.Error("call-to-update-pipeline-name-failed", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusNoContent)
})
}