CreateArticle persists the posted Article and returns it back to the client as an acknowledgement.
(w http.ResponseWriter, r *http.Request)
| 153 | // CreateArticle persists the posted Article and returns it |
| 154 | // back to the client as an acknowledgement. |
| 155 | func CreateArticle(w http.ResponseWriter, r *http.Request) { |
| 156 | data := &ArticleRequest{} |
| 157 | if err := render.Bind(r, data); err != nil { |
| 158 | render.Render(w, r, ErrInvalidRequest(err)) |
| 159 | return |
| 160 | } |
| 161 | |
| 162 | article := data.Article |
| 163 | dbNewArticle(article) |
| 164 | |
| 165 | render.Status(r, http.StatusCreated) |
| 166 | render.Render(w, r, NewArticleResponse(article)) |
| 167 | } |
| 168 | |
| 169 | // GetArticle returns the specific Article. You'll notice it just |
| 170 | // fetches the Article right off the context, as its understood that |
nothing calls this directly
no test coverage detected