You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

5 years ago
  1. package main
  2. import (
  3. "fmt"
  4. "main/config"
  5. "main/init/initRouter"
  6. "main/init/qmlog"
  7. "main/init/qmsql"
  8. "main/init/registTable"
  9. "net/http"
  10. "time"
  11. )
  12. // @title Swagger Example API
  13. // @version 0.0.1
  14. // @description This is a sample Server pets
  15. // @securityDefinitions.apikey ApiKeyAuth
  16. // @in header
  17. // @name x-token
  18. // @BasePath /
  19. func main() {
  20. qmlog.InitLog() // 初始化日志
  21. db:=qmsql.InitMysql(config.Dbconfig.Admin) // 链接初始化数据库
  22. registTable.RegistTable(db) //注册数据库表
  23. defer qmsql.DEFAULTDB.Close() // 程序结束前关闭数据库链接
  24. Router := initRouter.InitRouter() //注册路由
  25. qmlog.QMLog.Info("服务器开启") // 日志测试代码
  26. //Router.RunTLS(":443","ssl.pem", "ssl.key") // https支持 需要添加中间件
  27. s := &http.Server{
  28. Addr: ":8888",
  29. Handler: Router,
  30. ReadTimeout: 10 * time.Second,
  31. WriteTimeout: 10 * time.Second,
  32. MaxHeaderBytes: 1 << 20,
  33. }
  34. time.Sleep(10 * time.Microsecond)
  35. fmt.Printf(`欢迎使用 Gin-Vue-Admin
  36. 作者奇淼 And Spike666
  37. 微信shouzi_1994
  38. 默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
  39. 默认前端文件运行地址:http://127.0.0.1:8080
  40. `, s.Addr)
  41. _ = s.ListenAndServe()
  42. }