Delete 删除中间件
(c *gin.Context)
| 170 | |
| 171 | // Delete 删除中间件 |
| 172 | func (h *MiddlewareHandler) Delete(c *gin.Context) { |
| 173 | ctx := c.Request.Context() |
| 174 | id := c.Param("id") |
| 175 | |
| 176 | if err := h.store.Delete(ctx, "middlewares", id); err != nil { |
| 177 | if errors.Is(err, store.ErrNotFound) { |
| 178 | c.JSON(404, gin.H{"success": false, "error": gin.H{"code": "not_found", "message": "middleware not found"}}) |
| 179 | return |
| 180 | } |
| 181 | c.JSON(500, gin.H{"success": false, "error": gin.H{"code": "internal_error", "message": err.Error()}}) |
| 182 | return |
| 183 | } |
| 184 | |
| 185 | logging.Info(ctx, "middleware.deleted", map[string]any{"id": id}) |
| 186 | c.Status(204) |
| 187 | } |
| 188 | |
| 189 | // Enable 启用中间件 |
| 190 | func (h *MiddlewareHandler) Enable(c *gin.Context) { |