コード例 #1
0
ファイル: rename.go プロジェクト: xoebus/checkin
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)
	})
}