Add slug return on post

This commit is contained in:
Amarpreet Minhas 2019-10-26 11:29:58 -04:00
parent f5a37e34d4
commit 38e7f62c15

View file

@ -50,6 +50,7 @@ type ReturnError struct {
type ReturnSuccess struct { type ReturnSuccess struct {
Message string `json:"success"` Message string `json:"success"`
ID int `json:"id"` ID int `json:"id"`
Slug string `json:"slug",db:"slug"`
} }
type ReferenceID struct { type ReferenceID struct {
@ -169,7 +170,7 @@ func createBlogPost(w http.ResponseWriter, r *http.Request) {
} }
} }
returnSuccess := ReturnSuccess{Message: "post created", ID: article_id} returnSuccess := ReturnSuccess{Message: "post created", ID: article_id, Slug: as}
w.WriteHeader(http.StatusCreated) w.WriteHeader(http.StatusCreated)
render.JSON(w, r, returnSuccess) render.JSON(w, r, returnSuccess)
return return
@ -224,7 +225,7 @@ func updateBlogPostById(w http.ResponseWriter, r *http.Request) {
fmt.Println(err) fmt.Println(err)
return return
} }
returnSuccess := ReturnSuccess{Message: "post updated", ID: post.ID} returnSuccess := ReturnSuccess{Message: "post updated", ID: post.ID, Slug: post.Slug}
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
render.JSON(w, r, returnSuccess) render.JSON(w, r, returnSuccess)
return return