MCPcopy Create free account
hub / github.com/kataras/iris / Delete

Method Delete

_examples/database/mysql/api/category_handler.go:166–187  ·  view source on GitHub ↗

Delete removes a record from the database. Method: DELETE.

(ctx iris.Context)

Source from the content-addressed store, hash-verified

164// Delete removes a record from the database.
165// Method: DELETE.
166func (h *CategoryHandler) Delete(ctx iris.Context) {
167 id := ctx.Params().GetInt64Default("id", 0)
168
169 affected, err := h.service.DeleteByID(ctx.Request().Context(), id)
170 if err != nil {
171 if err == sql.ErrNoRows {
172 writeEntityNotFound(ctx)
173 return
174 }
175
176 debugf("CategoryHandler.Delete(DB): %v", err)
177 writeInternalServerError(ctx)
178 return
179 }
180
181 status := iris.StatusOK // StatusNoContent
182 if affected == 0 {
183 status = iris.StatusNotModified
184 }
185
186 ctx.StatusCode(status)
187}
188
189// Products.
190

Callers

nothing calls this directly

Calls 9

writeEntityNotFoundFunction · 0.85
debugfFunction · 0.85
writeInternalServerErrorFunction · 0.85
ParamsMethod · 0.80
ContextMethod · 0.80
RequestMethod · 0.80
DeleteByIDMethod · 0.65
StatusCodeMethod · 0.65
GetInt64DefaultMethod · 0.45

Tested by

no test coverage detected