package web import ( "cc/web/app/localtion" "cc/web/app/project" "cc/web/app/weather" "cc/web/middleware" "log" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/basicauth" ) // Go 启动web服务 func Go() { app := fiber.New(fiber.Config{ ServerHeader: "weather", AppName: "天气服务", }) app.Use(middleware.Log()) r := app.Group("api") // 路由组 weather.AddRouter(r) // 天气接口 app.Use(basicauth.New(basicauth.Config{ Users: map[string]string{ "weather": "lweather", }, })) project.AddRouter(r) // 项目接口 localtion.AddRouter(r) // 地点接口 if err := app.Listen(":52001"); err != nil { log.Panic("[web]端口监听失败:", err) } }