Delete deletes a session
(c *gin.Context)
| 238 | |
| 239 | // Delete deletes a session |
| 240 | func (h *SessionHandler) Delete(c *gin.Context) { |
| 241 | ctx := c.Request.Context() |
| 242 | id := c.Param("id") |
| 243 | |
| 244 | if err := (*h.store).Delete(ctx, "sessions", id); err != nil { |
| 245 | if errors.Is(err, store.ErrNotFound) { |
| 246 | c.JSON(http.StatusNotFound, gin.H{ |
| 247 | "success": false, |
| 248 | "error": gin.H{ |
| 249 | "code": "not_found", |
| 250 | "message": "Session not found", |
| 251 | }, |
| 252 | }) |
| 253 | return |
| 254 | } |
| 255 | c.JSON(http.StatusInternalServerError, gin.H{ |
| 256 | "success": false, |
| 257 | "error": gin.H{ |
| 258 | "code": "internal_error", |
| 259 | "message": "Failed to delete session: " + err.Error(), |
| 260 | }, |
| 261 | }) |
| 262 | return |
| 263 | } |
| 264 | |
| 265 | logging.Info(ctx, "session.deleted", map[string]any{ |
| 266 | "session_id": id, |
| 267 | }) |
| 268 | |
| 269 | c.Status(http.StatusNoContent) |
| 270 | } |
| 271 | |
| 272 | // GetMessages retrieves session messages |
| 273 | func (h *SessionHandler) GetMessages(c *gin.Context) { |