DeleteArticle removes an existing Article from our persistent store.
(w http.ResponseWriter, r *http.Request)
| 199 | |
| 200 | // DeleteArticle removes an existing Article from our persistent store. |
| 201 | func DeleteArticle(w http.ResponseWriter, r *http.Request) { |
| 202 | var err error |
| 203 | |
| 204 | // Assume if we've reach this far, we can access the article |
| 205 | // context because this handler is a child of the ArticleCtx |
| 206 | // middleware. The worst case, the recoverer middleware will save us. |
| 207 | article := r.Context().Value("article").(*Article) |
| 208 | |
| 209 | article, err = dbRemoveArticle(article.ID) |
| 210 | if err != nil { |
| 211 | render.Render(w, r, ErrInvalidRequest(err)) |
| 212 | return |
| 213 | } |
| 214 | |
| 215 | render.Render(w, r, NewArticleResponse(article)) |
| 216 | } |
| 217 | |
| 218 | // A completely separate router for administrator routes |
| 219 | func adminRouter() chi.Router { |
nothing calls this directly
no test coverage detected