package router // Register OPDS routes with device authentication // // Authentication Methods: // - Kobo devices: URL path parameter (e.g., /opds/devices/kobo-clara/catalog?token=dev_abc...) // (Token stored in device for use in stock firmware sync) // // - KOReader devices: Bearer token in Authorization header (e.g., Authorization: Bearer dev_xyz...) // (Token configured in device settings, passed to plugins) // // Middleware supports both methods (see device_auth.go) // Returns 401 Unauthorized if device token is missing, invalid, or device sync is disabled func registerOPDSRoutes(cfg *Config) { e := cfg.Echo // Require device authentication for all OPDS endpoints opds := e.Group("/opds/devices") opds.Use(cfg.DeviceAuthMiddleware.Authenticate) opds.GET("/:deviceId/catalog", cfg.OPDSHandler.GetDeviceCatalog) opds.GET("/:deviceId/search", cfg.OPDSHandler.SearchDeviceCatalog) opds.GET("/:deviceId/nav", cfg.OPDSHandler.GetDeviceNavigation) opds.GET("/:deviceId/download/:bookId", cfg.OPDSHandler.DownloadBook) opds.GET("/:deviceId/cover/:bookId", cfg.OPDSHandler.GetCoverImage) opds.GET("/:deviceId/formats/:bookId", cfg.OPDSHandler.ListFormats) }