/* * @description: * @Author: CP * @Date: 2020-08-23 21:32:48 * @FilePath: \construction_management\web\main.go */ package main import ( "fmt" "go.mod/bootstrap" "go.mod/web/middleware/identity" "go.mod/web/routes" "go.mod/web/utils" //_ "go.mod/web/docs" "github.com/iris-contrib/swagger/v12" // swagger middleware for Iris "github.com/iris-contrib/swagger/v12/swaggerFiles" // swagger embed files ) func newApp() *bootstrap.Bootstrapper { app := bootstrap.New("工程建设项目系统", "纵横软件") app.Bootstrap() app.Configure(identity.Configure, routes.Configure) return app } // @title 工程项目管理系统 API // @version 1.0 // @description 工程项目管理系统-接口 // @contact.name CP Support // @securityDefinitions.apikey ApiKeyAuth // @in header // @name X-CSRF-Token func main() { // 服务器集群的时候才需要区分这项设置 // 比如:根据服务器的IP、名称、端口号等,或者运行的参数 // if port == 6060 { // conf.RunningCrontabService = true // } app := newApp() // api接口文档配置 config := &swagger.Config{ URL: "http://localhost:6060/docs/swagger.json", //The url pointing to API definition } app.Get("/swagger/{any:path}", swagger.CustomWrapHandler(config, swaggerFiles.Handler)) // 由于新的项目管理服务器的数据库访问权限的问题,这里docker使用了host模式,启动端口需要区分 var port = 6070 debug := utils.GetEnvInfo("DEBUG") if debug == "uat" { port = 6060 } app.Listen(fmt.Sprintf(":%d", port)) }