예제 #1
0
func DeleteConfiguration(w http.ResponseWriter, r *http.Request){
	body, _ := ioutil.ReadAll(r.Body)
	vars := mux.Vars(r)

	var cfg = database.Configuration{}
	json.Unmarshal(body, &cfg)


	cfg.Name = vars["name"]

	oldConfig := database.GetConfigurationByName(cfg.Name)

	cfg.ID = oldConfig.ID

	ok := cfg.DeleteConfiguration()

	if ok{
		json.NewEncoder(w).Encode(cfg)
	}else{
		json.NewEncoder(w).Encode(models.ApiError{
			Code: "error",
			Message: "Error on execute",
		})
	}


}
예제 #2
0
파일: repos.go 프로젝트: joelbraga/navyhook
func GetRepo(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	repo := database.GetRepositoryByName(vars["name"])
	repo.Hooks = database.GetHooksByRepo(repo.ID)
	json.NewEncoder(w).Encode(repo)

}
예제 #3
0
func GetRepoActions(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	action := database.Action{
		Repository: vars["repo"],
	}

	json.NewEncoder(w).Encode(action.GetByRepository())

}
예제 #4
0
파일: repos.go 프로젝트: joelbraga/navyhook
func UpdateRepoHook(w http.ResponseWriter, r *http.Request) {
	body, _ := ioutil.ReadAll(r.Body)
	vars := mux.Vars(r)
	fmt.Println(vars)
	hook := database.Hook{}
	json.Unmarshal(body, &hook)

	hook.ID, _ = strconv.Atoi(vars["id"])

	hook.UpdateHook()

	json.NewEncoder(w).Encode(hook)

}
예제 #5
0
파일: repos.go 프로젝트: joelbraga/navyhook
func CreateRepoHook(w http.ResponseWriter, r *http.Request) {
	body, _ := ioutil.ReadAll(r.Body)
	vars := mux.Vars(r)

	repo := database.GetRepositoryByName(vars["name"])

	hook := database.Hook{}
	json.Unmarshal(body, &hook)

	hook.RepositoryId = repo.ID

	hook.SaveHook()

	json.NewEncoder(w).Encode(hook)

}