Esempio n. 1
0
func DeletePost(c web.C, w http.ResponseWriter, r *http.Request) {
	post := controllers.Post{}

	post.Id, _ = strconv.Atoi(c.URLParams["id"])
	post.Token = r.FormValue("token")
	helpers.RenderJSON(w, post.DeletePost(), http.StatusOK)
}
Esempio n. 2
0
func CreatePost(c web.C, w http.ResponseWriter, r *http.Request) {
	post := controllers.Post{}

	post.Title = r.FormValue("title")
	post.Content = r.FormValue("content")
	post.Token = r.FormValue("token")
	post.Important, _ = strconv.Atoi(r.FormValue("important"))
	helpers.RenderJSON(w, post.CreatePost(), http.StatusOK)
}
Esempio n. 3
0
func GetOwnPosts(c web.C, w http.ResponseWriter, r *http.Request) {
	post := controllers.Post{}

	post.Token = r.FormValue("token")
	err := post.GetOwnPosts()
	if err.Status == "KO" {
		helpers.RenderJSON(w, err, http.StatusOK)
	} else {
		post.PostsModel.Status = "OK"
		helpers.RenderJSON(w, post.PostsModel, http.StatusOK)
	}
}
Esempio n. 4
0
func GetPost(c web.C, w http.ResponseWriter, r *http.Request) {
	post := controllers.Post{}

	post.Id, _ = strconv.Atoi(c.URLParams["id"])
	post.Token = r.FormValue("token")
	err := post.GetPostById()
	if err.Status == "KO" {
		helpers.RenderJSON(w, err, http.StatusOK)
	} else {
		post.PostModel.Status = "OK"
		helpers.RenderJSON(w, post.PostModel, http.StatusOK)
	}
}