feat(legacy): setup routers in main.go

This commit is contained in:
Eli Yip 2025-06-03 10:19:06 +08:00
parent eb4f060cad
commit 5e23162fe2
No known key found for this signature in database
GPG Key ID: C98B69D4CF7D7EC5

10
main.go
View File

@ -3,6 +3,7 @@ package main
import (
"fmt"
"hands/api"
"hands/api/legacy"
"hands/cli"
"hands/config"
"hands/device"
@ -94,8 +95,15 @@ func main() {
models.RegisterDeviceTypes()
deviceManager := device.NewDeviceManager()
// 设置 API 路由
api.NewServer(device.NewDeviceManager()).SetupRoutes(r)
api.NewServer(deviceManager).SetupRoutes(r)
legacyServer, err := legacy.NewLegacyServer(deviceManager)
if err != nil {
log.Fatalf("❌ 初始化旧版 API 失败: %v", err)
}
legacyServer.SetupRoutes(r)
// 启动服务器
log.Printf("🌐 CAN 控制服务运行在 http://localhost:%s", config.Config.WebPort)