Revert unauthorized route changes made during router refactoring: Device Routes: - Change :token back to :registration_id in approve/reject routes - Keep routes in correct location (approve/reject in protected group) OPDS Routes: - Restore /opds/devices/:deviceId/* structure (was /opds/:id/*) - Add back missing :bookId parameter for download/cover/formats - Change 'navigation' back to 'nav' Queue Routes: - Add missing admin-only routes - Add missing device-specific queue management routes All routes now match original main.go signatures exactly. Breaking changes reverted - API contract restored.
26 lines
925 B
Go
26 lines
925 B
Go
package router
|
|
|
|
func registerDeviceRoutes(cfg *Config) {
|
|
e := cfg.Echo
|
|
|
|
// JWT middleware
|
|
jwtMiddleware := createJWTMiddleware(cfg)
|
|
|
|
// Protected routes
|
|
protected := e.Group("/api", jwtMiddleware)
|
|
devices := protected.Group("/devices")
|
|
|
|
// Public device registration routes (no auth required)
|
|
e.POST("/api/devices/register", cfg.DeviceHandler.InitiateRegistration)
|
|
e.POST("/api/devices/register/status", cfg.DeviceHandler.CheckRegistrationStatus)
|
|
|
|
// Device management routes (protected)
|
|
devices.GET("", cfg.DeviceHandler.ListDevices)
|
|
devices.GET("/:id", cfg.DeviceHandler.GetDevice)
|
|
devices.PUT("/:id", cfg.DeviceHandler.UpdateDevice)
|
|
devices.DELETE("/:id", cfg.DeviceHandler.DeleteDevice)
|
|
devices.GET("/pending", cfg.DeviceHandler.ListPendingRegistrations)
|
|
devices.GET("/approve/:registration_id", cfg.DeviceHandler.ApproveDevice)
|
|
devices.POST("/reject/:registration_id", cfg.DeviceHandler.RejectDevice)
|
|
}
|