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

Function CreateArticle

_examples/rest/main.go:155–167  ·  view source on GitHub ↗

CreateArticle persists the posted Article and returns it back to the client as an acknowledgement.

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

Source from the content-addressed store, hash-verified

153// CreateArticle persists the posted Article and returns it
154// back to the client as an acknowledgement.
155func 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

Callers

nothing calls this directly

Calls 6

ErrInvalidRequestFunction · 0.85
dbNewArticleFunction · 0.85
NewArticleResponseFunction · 0.70
StatusMethod · 0.65
BindMethod · 0.45
RenderMethod · 0.45

Tested by

no test coverage detected