refactor(handlers): update all handlers for Echo v5 compatibility

Update all handler functions to use *echo.Context (pointer) instead of echo.Context (value) as required by Echo v5.

Changes across all handler files:
- analytics.go: Update handler signatures
- auth.go: Update authentication handler signatures
- book_matching.go: Update matching handler signatures
- collections.go: Update collection handler signatures
- collections_preview_test.go: Update test signatures
- commonhandlers.go: Update common handler signatures
- conflicts.go: Update conflict handler signatures
- context.go: Update context handler signatures
- dashboard.go: Update dashboard handler signatures
- devices.go: Update device handler signatures
- jobs.go: Update job handler signatures
- kobo.go: Update Kobo handler signatures
- koreader.go: Update Koreader handler signatures
- library.go: Update library handler signatures
- matching.go: Update matching handler signatures
- media.go: Update media handler signatures
- opds.go: Update OPDS handler signatures
- progress.go: Update progress handler signatures
- queue.go: Update queue handler signatures
- refresh_token.go: Update token handler signatures
- scanner.go: Update scanner handler signatures
- sidecar.go: Update sidecar handler signatures
- sync.go: Update sync handler signatures
- system_settings.go: Update settings handler signatures
- websocket.go: Update WebSocket handler signatures

All handlers now properly implement Echo v5's pointer-based context pattern.
This change is necessary for type safety and compatibility with Echo v5's
improved context handling and WebSocket support.
This commit is contained in:
2026-03-06 14:00:28 -05:00
parent 784326e2c4
commit 1e05470fbb
25 changed files with 213 additions and 213 deletions
+13 -13
View File
@@ -12,7 +12,7 @@ import (
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"github.com/skip2/go-qrcode"
"golang.org/x/crypto/bcrypt"
)
@@ -104,7 +104,7 @@ type PendingRegistration struct {
var pendingRegistrations = make(map[string]*PendingRegistration)
func (h *DeviceHandler) InitiateRegistration(c echo.Context) error {
func (h *DeviceHandler) InitiateRegistration(c *echo.Context) error {
req := DeviceRegistrationRequest{}
if err := c.Bind(&req); err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid request format"})
@@ -157,7 +157,7 @@ func (h *DeviceHandler) InitiateRegistration(c echo.Context) error {
return c.JSON(http.StatusCreated, response)
}
func (h *DeviceHandler) CheckRegistrationStatus(c echo.Context) error {
func (h *DeviceHandler) CheckRegistrationStatus(c *echo.Context) error {
req := DeviceAuthStatusRequest{}
if err := c.Bind(&req); err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid request format"})
@@ -230,7 +230,7 @@ func (h *DeviceHandler) CheckRegistrationStatus(c echo.Context) error {
})
}
func (h *DeviceHandler) ListDevices(c echo.Context) error {
func (h *DeviceHandler) ListDevices(c *echo.Context) error {
userID := c.Get("user_id").(string)
userUUID, err := uuid.Parse(userID)
if err != nil {
@@ -274,7 +274,7 @@ func (h *DeviceHandler) ListDevices(c echo.Context) error {
})
}
func (h *DeviceHandler) GetDevicesData(c echo.Context) ([]DeviceInfo, error) {
func (h *DeviceHandler) GetDevicesData(c *echo.Context) ([]DeviceInfo, error) {
userID := c.Get("user_id").(string)
userUUID, err := uuid.Parse(userID)
if err != nil {
@@ -315,7 +315,7 @@ func (h *DeviceHandler) GetDevicesData(c echo.Context) ([]DeviceInfo, error) {
return deviceList, nil
}
func (h *DeviceHandler) GetDevice(c echo.Context) error {
func (h *DeviceHandler) GetDevice(c *echo.Context) error {
userID := c.Get("user_id")
if userID == nil {
return c.JSON(http.StatusUnauthorized, map[string]string{"error": "unauthorized"})
@@ -363,7 +363,7 @@ func (h *DeviceHandler) GetDevice(c echo.Context) error {
})
}
func (h *DeviceHandler) UpdateDevice(c echo.Context) error {
func (h *DeviceHandler) UpdateDevice(c *echo.Context) error {
userID := c.Get("user_id").(string)
userUUID, err := uuid.Parse(userID)
if err != nil {
@@ -458,7 +458,7 @@ func (h *DeviceHandler) UpdateDevice(c echo.Context) error {
})
}
func (h *DeviceHandler) DeleteDevice(c echo.Context) error {
func (h *DeviceHandler) DeleteDevice(c *echo.Context) error {
userID := c.Get("user_id").(string)
userUUID, err := uuid.Parse(userID)
if err != nil {
@@ -488,7 +488,7 @@ func (h *DeviceHandler) DeleteDevice(c echo.Context) error {
return c.NoContent(http.StatusNoContent)
}
func (h *DeviceHandler) RegenerateDeviceToken(c echo.Context) error {
func (h *DeviceHandler) RegenerateDeviceToken(c *echo.Context) error {
// Verify JWT authentication
userID := c.Get("user_id").(string)
userUUID, err := uuid.Parse(userID)
@@ -573,7 +573,7 @@ func (h *DeviceHandler) RegenerateDeviceToken(c echo.Context) error {
})
}
func (h *DeviceHandler) ApproveDevice(c echo.Context) error {
func (h *DeviceHandler) ApproveDevice(c *echo.Context) error {
userID := c.Get("user_id").(string)
userUUID, err := uuid.Parse(userID)
if err != nil {
@@ -603,7 +603,7 @@ func (h *DeviceHandler) ApproveDevice(c echo.Context) error {
})
}
func (h *DeviceHandler) RejectDevice(c echo.Context) error {
func (h *DeviceHandler) RejectDevice(c *echo.Context) error {
registrationID := c.Param("registration_id")
_, exists := pendingRegistrations[registrationID]
@@ -618,7 +618,7 @@ func (h *DeviceHandler) RejectDevice(c echo.Context) error {
})
}
func (h *DeviceHandler) GetPendingRegistrationsData(c echo.Context) ([]map[string]interface{}, error) {
func (h *DeviceHandler) GetPendingRegistrationsData(c *echo.Context) ([]map[string]interface{}, error) {
userID := c.Get("user_id").(string)
userUUID, err := uuid.Parse(userID)
if err != nil {
@@ -643,7 +643,7 @@ func (h *DeviceHandler) GetPendingRegistrationsData(c echo.Context) ([]map[strin
return registrations, nil
}
func (h *DeviceHandler) ListPendingRegistrations(c echo.Context) error {
func (h *DeviceHandler) ListPendingRegistrations(c *echo.Context) error {
userID := c.Get("user_id").(string)
userUUID, err := uuid.Parse(userID)
if err != nil {