main.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * @description:
  3. * @Author: CP
  4. * @Date: 2020-08-23 21:32:48
  5. * @FilePath: \construction_management\web\main.go
  6. */
  7. package main
  8. import (
  9. "fmt"
  10. "go.mod/bootstrap"
  11. "go.mod/web/middleware/identity"
  12. "go.mod/web/routes"
  13. //_ "go.mod/web/docs"
  14. "github.com/iris-contrib/swagger/v12" // swagger middleware for Iris
  15. "github.com/iris-contrib/swagger/v12/swaggerFiles" // swagger embed files
  16. )
  17. var port = 6060
  18. func newApp() *bootstrap.Bootstrapper {
  19. // 初始化应用
  20. app := bootstrap.New("工程建设项目系统", "纵横软件")
  21. app.Bootstrap()
  22. //, csrf.Configure
  23. app.Configure(identity.Configure, routes.Configure)
  24. return app
  25. }
  26. // @title 工程项目管理系统 API
  27. // @version 1.0
  28. // @description 工程项目管理系统-接口
  29. // @contact.name CP Support
  30. // @securityDefinitions.apikey ApiKeyAuth
  31. // @in header
  32. // @name X-CSRF-Token
  33. func main() {
  34. // 服务器集群的时候才需要区分这项设置
  35. // 比如:根据服务器的IP、名称、端口号等,或者运行的参数
  36. // if port == 6060 {
  37. // conf.RunningCrontabService = true
  38. // }
  39. app := newApp()
  40. // api接口文档配置
  41. config := &swagger.Config{
  42. URL: "http://localhost:6060/docs/swagger.json", //The url pointing to API definition
  43. }
  44. app.Get("/swagger/{any:path}", swagger.CustomWrapHandler(config, swaggerFiles.Handler))
  45. app.Listen(fmt.Sprintf(":%d", port))
  46. }