Major refactoring milestone - migrate all routes from main.go to internal/router/ package: ## Changes ### cmd/server/main.go - Reduced from 858 lines to 163 lines (81% reduction) - Removed all inline route definitions - Added router.RegisterRoutes() call with full config - Clean separation: setup → router registration → server start ### internal/router/ package Created comprehensive route organization: - router.go: Main router setup and JWT middleware - auth.go: Authentication routes (login, register, profile, etc.) - library.go: Library management routes - device.go: Device registration and management - sync.go: KOReader/Kobo sync + book matching + WebSocket - media.go: Media download, shelves, bulk operations - conflicts.go: Conflict resolution routes - analytics.go: Analytics API routes - queue.go: Sync queue management - opds.go: OPDS feed routes - frontend.go: SSR pages (/login, /admin, /dashboard, etc.) - docs.go: Documentation routes - helpers.go: Template rendering helpers ## Verification ✅ All 26 guideline checks pass ✅ Code compiles successfully ✅ Zero API behavior changes (100% compatible) ✅ Follows Go standard project layout ## Breaking Changes None - API compatibility fully maintained
16 lines
609 B
Go
16 lines
609 B
Go
package router
|
|
|
|
func registerOPDSRoutes(cfg *Config) {
|
|
e := cfg.Echo
|
|
|
|
// OPDS routes (public - device authentication optional)
|
|
// Note: OPDSHandler implements its own device authentication
|
|
e.GET("/opds/:id", cfg.OPDSHandler.GetDeviceCatalog)
|
|
e.GET("/opds/:id/search", cfg.OPDSHandler.SearchDeviceCatalog)
|
|
e.GET("/opds/:id/download", cfg.OPDSHandler.DownloadBook)
|
|
e.GET("/opds/:id/cover", cfg.OPDSHandler.GetCoverImage)
|
|
e.GET("/opds/:id/navigation", cfg.OPDSHandler.GetDeviceNavigation)
|
|
e.GET("/opds/:id/formats", cfg.OPDSHandler.ListFormats)
|
|
e.POST("/opds/register", cfg.OPDSHandler.RegisterOPDS)
|
|
}
|