示例#1
0
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)

}
示例#2
0
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)

}