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