/* * @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/docs" "github.com/iris-contrib/swagger/v12" // swagger middleware for Iris "github.com/iris-contrib/swagger/v12/swaggerFiles" // swagger embed files ) var port = 6060 func newApp() *bootstrap.Bootstrapper { // 初始化应用 app := bootstrap.New("工程建设项目系统", "纵横软件") app.Bootstrap() //, csrf.Configure 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)) app.Listen(fmt.Sprintf(":%d", port)) }