feat: refactor routing structure by moving routes to a dedicated package and updating service initialization
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
package server
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
"tts/internal/config"
|
"tts/internal/config"
|
||||||
|
"tts/internal/http/routes"
|
||||||
)
|
)
|
||||||
|
|
||||||
// App 表示整个TTS应用程序
|
// App 表示整个TTS应用程序
|
||||||
@@ -26,13 +27,13 @@ func NewApp(configPath string) (*App, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化服务
|
// 初始化服务
|
||||||
ttsService, err := InitializeServices(cfg)
|
ttsService, err := routes.InitializeServices(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("初始化服务失败: %w", err)
|
return nil, fmt.Errorf("初始化服务失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置路由
|
// 设置路由
|
||||||
handler, err := SetupRoutes(cfg, ttsService)
|
handler, err := routes.SetupRoutes(cfg, ttsService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("设置路由失败: %w", err)
|
return nil, fmt.Errorf("设置路由失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user