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

Method Delete

_examples/database/mysql/api/product_handler.go:157–173  ·  view source on GitHub ↗

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

(ctx iris.Context)

Source from the content-addressed store, hash-verified

155// Delete removes a record from the database.
156// Method: DELETE.
157func (h *ProductHandler) Delete(ctx iris.Context) {
158 id := ctx.Params().GetInt64Default("id", 0)
159
160 affected, err := h.service.DeleteByID(ctx.Request().Context(), id)
161 if err != nil {
162 debugf("ProductHandler.Delete(DB): %v", err)
163 writeInternalServerError(ctx)
164 return
165 }
166
167 status := iris.StatusOK // StatusNoContent
168 if affected == 0 {
169 status = iris.StatusNotModified
170 }
171
172 ctx.StatusCode(status)
173}

Callers

nothing calls this directly

Calls 8

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