ai_scheduler/internal/server/http.go

40 lines
782 B
Go

package server
import (
"ai_scheduler/internal/gateway"
"ai_scheduler/internal/server/router"
"ai_scheduler/internal/services"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/recover"
)
type HTTPServer struct {
app *fiber.App
service *services.ChatService
session *services.SessionService
gateway *gateway.Gateway
}
func NewHTTPServer(
service *services.ChatService,
session *services.SessionService,
task *services.TaskService,
gateway *gateway.Gateway,
) *fiber.App {
//构建 server
app := initRoute()
router.SetupRoutes(app, service, session, task, gateway)
return app
}
func initRoute() *fiber.App {
app := fiber.New()
app.Use(
recover.New(),
logger.New(),
)
return app
}