P0 fixes: - ModelError.Is(): use exact matching instead of substring contains() - shouldClearStickySession: add context param for cancellation/tracing P1 fixes: - TODO stubs: return 501 Not Implemented errors - validateInstanceSignature: deduplicate to shared validateCodeSignature() - Error messages: standardize to English only - http.go: remove pseudo if-else with duplicate branches
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
package routes
|
|
|
|
import (
|
|
"github.com/Wei-Shaw/sub2api/internal/handler"
|
|
"github.com/Wei-Shaw/sub2api/internal/server/middleware"
|
|
"github.com/Wei-Shaw/sub2api/internal/service"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// RegisterSoraClientRoutes 注册 Sora 客户端 API 路由(需要用户认证)。
|
|
func RegisterSoraClientRoutes(
|
|
v1 *gin.RouterGroup,
|
|
h *handler.Handlers,
|
|
jwtAuth middleware.JWTAuthMiddleware,
|
|
settingService *service.SettingService,
|
|
) {
|
|
if h.SoraClient == nil {
|
|
return
|
|
}
|
|
|
|
authenticated := v1.Group("/sora")
|
|
authenticated.Use(gin.HandlerFunc(jwtAuth))
|
|
authenticated.Use(middleware.BackendModeUserGuard(settingService))
|
|
{
|
|
authenticated.POST("/generate", h.SoraClient.Generate)
|
|
authenticated.GET("/generations", h.SoraClient.ListGenerations)
|
|
authenticated.GET("/generations/:id", h.SoraClient.GetGeneration)
|
|
authenticated.DELETE("/generations/:id", h.SoraClient.DeleteGeneration)
|
|
authenticated.POST("/generations/:id/cancel", h.SoraClient.CancelGeneration)
|
|
authenticated.POST("/generations/:id/save", h.SoraClient.SaveToStorage)
|
|
authenticated.GET("/quota", h.SoraClient.GetQuota)
|
|
authenticated.GET("/models", h.SoraClient.GetModels)
|
|
authenticated.GET("/storage-status", h.SoraClient.GetStorageStatus)
|
|
}
|
|
}
|