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) }
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) } }
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) } }
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) }