main.go 753 字节
Newer Older
Mr.奇淼('s avatar
Mr.奇淼( 已提交
1 2 3 4
package main

import (
	"main/config"
5
	"main/init/initRouter"
Mr.奇淼('s avatar
Mr.奇淼( 已提交
6 7
	"main/init/qmlog"
	"main/init/qmsql"
8
	"main/init/registTable"
Mr.奇淼('s avatar
Mr.奇淼( 已提交
9 10 11 12
	"net/http"
	"time"
)

Mr.奇淼('s avatar
Mr.奇淼( 已提交
13 14 15 16 17 18 19
// @title Swagger Example API
// @version 0.0.1
// @description This is a sample Server pets
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name x-token
// @BasePath /
Mr.奇淼('s avatar
Mr.奇淼( 已提交
20
func main() {
Mr.奇淼('s avatar
Mr.奇淼( 已提交
21 22 23
	qmlog.InitLog()
	registTable.RegistTable(qmsql.InitMysql(config.Dbconfig.Admin))
	defer qmsql.DEFAULTDB.Close()
24
	Router := initRouter.InitRouter()
Mr.奇淼('s avatar
Mr.奇淼( 已提交
25
	//qmlog.QMLog.Info("服务器开启") // 日志测试代码
Mr.奇淼('s avatar
Mr.奇淼( 已提交
26 27
	s := &http.Server{
		Addr:           ":8888",
28
		Handler:        Router,
Mr.奇淼('s avatar
Mr.奇淼( 已提交
29 30 31 32 33 34
		ReadTimeout:    10 * time.Second,
		WriteTimeout:   10 * time.Second,
		MaxHeaderBytes: 1 << 20,
	}
	_ = s.ListenAndServe()
}