Delete removes a record from the database. Method: DELETE.
(ctx iris.Context)
| 155 | // Delete removes a record from the database. |
| 156 | // Method: DELETE. |
| 157 | func (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 | } |
nothing calls this directly
no test coverage detected