1 Star 0 Fork 40

青蛙翻身/go-admin

forked from hequan/go-admin 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
main.go 1.59 KB
Copy Edit Raw Blame History
何全 authored 2021-06-25 10:50 . 更新说明文件
package main
import (
"fmt"
"go-admin/middleware/inject"
"go-admin/pkg/setting"
"go-admin/routers"
"log"
"net/http"
)
// @title go-admin
// @version 2.0
// @description go-admin
// @termsOfService https://github.com/hequan2017/go-admin
// @contact.name hequan
// @contact.url https://github.com/hequan2017
// @contact.email hequan2011@sina.com
// @license.name MIT
// @license.url https://github.com/hequan2017/go-admin/blob/master/LICENSE
// @host 127.0.0.1:8000
// @BasePath
func main() {
err := inject.LoadCasbinPolicyData()
if err != nil {
panic("加载casbin策略数据发生错误: " + err.Error())
}
routersInit := routers.InitRouter()
readTimeout := setting.ServerSetting.ReadTimeout
writeTimeout := setting.ServerSetting.WriteTimeout
endPoint := fmt.Sprintf(":%d", setting.ServerSetting.HttpPort)
maxHeaderBytes := 1 << 20
server := &http.Server{
Addr: endPoint,
Handler: routersInit,
ReadTimeout: readTimeout,
WriteTimeout: writeTimeout,
MaxHeaderBytes: maxHeaderBytes,
}
log.Printf("[info] start http server listening %s", endPoint)
_ = server.ListenAndServe()
// If you want Graceful Restart, you need a Unix system and download github.com/fvbock/endless
//endless.DefaultReadTimeOut = readTimeout
//endless.DefaultWriteTimeOut = writeTimeout
//endless.DefaultMaxHeaderBytes = maxHeaderBytes
//server := endless.NewServer(endPoint, routersInit)
//server.BeforeBegin = func(add string) {
// log.Printf("Actual pid is %d", syscall.Getpid())
//}
//
//err := server.ListenAndServe()
//if err != nil {
// log.Printf("Server err: %v", err)
//}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/11720270/go-admin.git
git@gitee.com:11720270/go-admin.git
11720270
go-admin
go-admin
master

Search