42 lines
907 B
Go
42 lines
907 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
|
|
callback *services.CallbackService
|
|
}
|
|
|
|
func NewHTTPServer(
|
|
service *services.ChatService,
|
|
session *services.SessionService,
|
|
task *services.TaskService,
|
|
gateway *gateway.Gateway,
|
|
callback *services.CallbackService,
|
|
) *fiber.App {
|
|
//构建 server
|
|
app := initRoute()
|
|
router.SetupRoutes(app, service, session, task, gateway, callback)
|
|
return app
|
|
}
|
|
|
|
func initRoute() *fiber.App {
|
|
app := fiber.New()
|
|
app.Use(
|
|
recover.New(),
|
|
logger.New(),
|
|
)
|
|
return app
|
|
}
|