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
+14 -14
View File
@@ -11,7 +11,7 @@ import (
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
)
type LibraryHandler struct {
@@ -48,7 +48,7 @@ type SetLibraryVisibilityRequest struct {
}
// GetLibraryTypes retrieves all available library types
func (h *LibraryHandler) GetLibraryTypes(c echo.Context) error {
func (h *LibraryHandler) GetLibraryTypes(c *echo.Context) error {
types, err := h.libraryService.GetLibraryTypes(c.Request().Context())
if err != nil {
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
@@ -57,7 +57,7 @@ func (h *LibraryHandler) GetLibraryTypes(c echo.Context) error {
}
// CreateLibrary creates a new library
func (h *LibraryHandler) CreateLibrary(c echo.Context) error {
func (h *LibraryHandler) CreateLibrary(c *echo.Context) error {
user := c.Get("user").(database.Users)
userUUID := user.ID.Bytes
@@ -84,7 +84,7 @@ func (h *LibraryHandler) CreateLibrary(c echo.Context) error {
}
// GetLibrary retrieves a specific library
func (h *LibraryHandler) GetLibrary(c echo.Context) error {
func (h *LibraryHandler) GetLibrary(c *echo.Context) error {
libraryID, err := parseUUID(c.Param("id"))
if err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid library id"})
@@ -99,7 +99,7 @@ func (h *LibraryHandler) GetLibrary(c echo.Context) error {
}
// ListLibraries retrieves all libraries (admin only)
func (h *LibraryHandler) ListLibraries(c echo.Context) error {
func (h *LibraryHandler) ListLibraries(c *echo.Context) error {
libraries, err := h.libraryService.ListLibraries(c.Request().Context())
if err != nil {
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
@@ -109,7 +109,7 @@ func (h *LibraryHandler) ListLibraries(c echo.Context) error {
}
// GetUserVisibleLibraries retrieves libraries visible to the current user
func (h *LibraryHandler) GetUserVisibleLibraries(c echo.Context) error {
func (h *LibraryHandler) GetUserVisibleLibraries(c *echo.Context) error {
user := MustGetAuthenticatedUser(c)
libraries, err := h.libraryService.GetUserVisibleLibraries(c.Request().Context(), user.ID)
@@ -121,7 +121,7 @@ func (h *LibraryHandler) GetUserVisibleLibraries(c echo.Context) error {
}
// UpdateLibrary updates an existing library
func (h *LibraryHandler) UpdateLibrary(c echo.Context) error {
func (h *LibraryHandler) UpdateLibrary(c *echo.Context) error {
libraryID, err := parseUUID(c.Param("id"))
if err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid library id"})
@@ -149,7 +149,7 @@ func (h *LibraryHandler) UpdateLibrary(c echo.Context) error {
}
// DeleteLibrary deletes a library
func (h *LibraryHandler) DeleteLibrary(c echo.Context) error {
func (h *LibraryHandler) DeleteLibrary(c *echo.Context) error {
libraryID, err := parseUUID(c.Param("id"))
if err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid library id"})
@@ -164,7 +164,7 @@ func (h *LibraryHandler) DeleteLibrary(c echo.Context) error {
}
// AddLibraryFolder adds a folder to a library
func (h *LibraryHandler) AddLibraryFolder(c echo.Context) error {
func (h *LibraryHandler) AddLibraryFolder(c *echo.Context) error {
libraryID, err := parseUUID(c.Param("id"))
if err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid library id"})
@@ -213,7 +213,7 @@ func (h *LibraryHandler) AddLibraryFolder(c echo.Context) error {
}
// GetLibraryFolders retrieves all folders for a library
func (h *LibraryHandler) GetLibraryFolders(c echo.Context) error {
func (h *LibraryHandler) GetLibraryFolders(c *echo.Context) error {
libraryID, err := parseUUID(c.Param("id"))
if err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid library id"})
@@ -228,7 +228,7 @@ func (h *LibraryHandler) GetLibraryFolders(c echo.Context) error {
}
// DeleteLibraryFolder removes a folder from a library
func (h *LibraryHandler) DeleteLibraryFolder(c echo.Context) error {
func (h *LibraryHandler) DeleteLibraryFolder(c *echo.Context) error {
libraryID, err := parseUUID(c.Param("id"))
if err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid library id"})
@@ -251,7 +251,7 @@ func (h *LibraryHandler) DeleteLibraryFolder(c echo.Context) error {
}
// BrowseDirectories returns directory listings for folder browser UI
func (h *LibraryHandler) BrowseDirectories(c echo.Context) error {
func (h *LibraryHandler) BrowseDirectories(c *echo.Context) error {
path := c.QueryParam("path")
if path == "" {
path = "/" // Start from root
@@ -270,7 +270,7 @@ func (h *LibraryHandler) BrowseDirectories(c echo.Context) error {
}
// SetLibraryVisibility sets library visibility for a user
func (h *LibraryHandler) SetLibraryVisibility(c echo.Context) error {
func (h *LibraryHandler) SetLibraryVisibility(c *echo.Context) error {
user := c.Get("user").(database.Users)
var req SetLibraryVisibilityRequest
@@ -300,7 +300,7 @@ func (h *LibraryHandler) SetLibraryVisibility(c echo.Context) error {
}
// GetLibraryStats retrieves statistics for a library
func (h *LibraryHandler) GetLibraryStats(c echo.Context) error {
func (h *LibraryHandler) GetLibraryStats(c *echo.Context) error {
libraryID, err := parseUUID(c.Param("id"))
if err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid library id"})