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:
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v5"
|
||||
)
|
||||
|
||||
type OPDSHandler struct {
|
||||
@@ -39,7 +39,7 @@ func NewOPDSHandler(db *database.Queries, libraryService *services.LibraryServic
|
||||
}
|
||||
|
||||
// Helper function to get base URLs from system config
|
||||
func (h *OPDSHandler) getBaseURLs(c echo.Context) (string, string, error) {
|
||||
func (h *OPDSHandler) getBaseURLs(c *echo.Context) (string, string, error) {
|
||||
baseURL, err := h.db.GetSystemConfig(c.Request().Context(), "base_url")
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("failed to get base_url from config: %w", err)
|
||||
@@ -54,7 +54,7 @@ func (h *OPDSHandler) getBaseURLs(c echo.Context) (string, string, error) {
|
||||
}
|
||||
|
||||
// GetDeviceCatalog returns the OPDS catalog feed for a device
|
||||
func (h *OPDSHandler) GetDeviceCatalog(c echo.Context) error {
|
||||
func (h *OPDSHandler) GetDeviceCatalog(c *echo.Context) error {
|
||||
deviceID := c.Param("deviceId")
|
||||
|
||||
page := c.QueryParam("page")
|
||||
@@ -218,7 +218,7 @@ func (h *OPDSHandler) GetDeviceCatalog(c echo.Context) error {
|
||||
}
|
||||
|
||||
// SearchDeviceCatalog searches the OPDS catalog for a device
|
||||
func (h *OPDSHandler) SearchDeviceCatalog(c echo.Context) error {
|
||||
func (h *OPDSHandler) SearchDeviceCatalog(c *echo.Context) error {
|
||||
deviceID := c.Param("deviceId")
|
||||
|
||||
query := c.QueryParam("q")
|
||||
@@ -335,7 +335,7 @@ func (h *OPDSHandler) SearchDeviceCatalog(c echo.Context) error {
|
||||
}
|
||||
|
||||
// DownloadBook downloads a book with optional format conversion
|
||||
func (h *OPDSHandler) DownloadBook(c echo.Context) error {
|
||||
func (h *OPDSHandler) DownloadBook(c *echo.Context) error {
|
||||
deviceID := c.Param("deviceId")
|
||||
bookID := c.Param("bookId")
|
||||
format := c.QueryParam("format") // epub, kepub, pdf, cbz
|
||||
@@ -488,7 +488,7 @@ func (h *OPDSHandler) DownloadBook(c echo.Context) error {
|
||||
}
|
||||
|
||||
// GetCoverImage serves a book's cover image
|
||||
func (h *OPDSHandler) GetCoverImage(c echo.Context) error {
|
||||
func (h *OPDSHandler) GetCoverImage(c *echo.Context) error {
|
||||
deviceID := c.Param("deviceId")
|
||||
bookID := c.Param("bookId")
|
||||
|
||||
@@ -578,7 +578,7 @@ func (h *OPDSHandler) GetCoverImage(c echo.Context) error {
|
||||
}
|
||||
|
||||
// GetDeviceNavigation returns the OPDS navigation feed for a device
|
||||
func (h *OPDSHandler) GetDeviceNavigation(c echo.Context) error {
|
||||
func (h *OPDSHandler) GetDeviceNavigation(c *echo.Context) error {
|
||||
deviceID := c.Param("deviceId")
|
||||
|
||||
// Get base URLs
|
||||
@@ -629,7 +629,7 @@ func (h *OPDSHandler) GetDeviceNavigation(c echo.Context) error {
|
||||
}
|
||||
|
||||
// ListFormats lists available formats for a book
|
||||
func (h *OPDSHandler) ListFormats(c echo.Context) error {
|
||||
func (h *OPDSHandler) ListFormats(c *echo.Context) error {
|
||||
deviceID := c.Param("deviceId")
|
||||
bookID := c.Param("bookId")
|
||||
|
||||
@@ -755,7 +755,7 @@ func (h *OPDSHandler) ListFormats(c echo.Context) error {
|
||||
}
|
||||
|
||||
// RegisterOPDS registers a device for OPDS access
|
||||
func (h *OPDSHandler) RegisterOPDS(c echo.Context) error {
|
||||
func (h *OPDSHandler) RegisterOPDS(c *echo.Context) error {
|
||||
deviceID := c.Param("deviceId")
|
||||
|
||||
// Parse device ID
|
||||
|
||||
Reference in New Issue
Block a user