ai_scheduler/internal/server/http.go

56 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package server
import (
"ai_scheduler/internal/config"
"ai_scheduler/internal/server/router"
"ai_scheduler/internal/services/advice"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/recover"
)
func NewHTTPServer(
cfg *config.Config,
adviceFile *advice.FileService,
adviceData *advice.AdvicerService,
adviceChat *advice.ChatService,
adviceProject *advice.ProjectService,
adviceTalkSkill *advice.TalkSkillService,
adviceClient *advice.ClientService,
industry *advice.IndustryService,
admin *advice.AdminService,
modelSup *advice.ModelSupService,
activity *advice.ActivityService,
wxHook *advice.WxHookService,
smartService *advice.SmartService,
wxProxy *advice.WxProxyService,
wsHub *advice.WxWsHub,
adviceCustomer *advice.CustomerService,
adviceLabel *advice.LabelService,
) *fiber.App {
//构建 server
app := initRoute()
// 提供静态前端:/ -> web/index.html, /admin.html, /project.html
// 上传文件静态托管:/upload/...(聊天记录等)
app.Static("/upload", "./upload")
app.Static("/", "./web")
router.SetupRoutes(cfg, app, adviceFile, adviceData, adviceChat, adviceProject, adviceTalkSkill, adviceClient, industry, admin, modelSup, activity, wxHook, smartService, wxProxy, wsHub, adviceCustomer, adviceLabel)
return app
}
func initRoute() *fiber.App {
app := fiber.New(fiber.Config{
// 提升请求体上限,支持上传聊天记录文件(默认 4MB)
BodyLimit: 32 * 1024 * 1024,
})
app.Use(
recover.New(),
logger.New(),
)
return app
}