MCPcopy
hub / github.com/go-chi/chi / DeleteArticle

Function DeleteArticle

_examples/rest/main.go:201–216  ·  view source on GitHub ↗

DeleteArticle removes an existing Article from our persistent store.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

199
200// DeleteArticle removes an existing Article from our persistent store.
201func 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
219func adminRouter() chi.Router {

Callers

nothing calls this directly

Calls 5

dbRemoveArticleFunction · 0.85
ErrInvalidRequestFunction · 0.85
ValueMethod · 0.80
NewArticleResponseFunction · 0.70
RenderMethod · 0.45

Tested by

no test coverage detected