代码拉取完成,页面将自动刷新
// Package hook
// @Link https://gitee.com/linngc/center.gf
// @Copyright Copyright (c) 2022 webos CLI
// @Author linngc
// @License
// @title 服务加载之前
package hook
import (
"context"
"gitee.com/linngc/center.gf/contrib/module/command/utility"
"gitee.com/linngc/center.gf/utility/tools/env"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/net/gipv4"
"github.com/gogf/gf/v2/os/gfile"
)
// bindStatusHandler 前台系统自定义错误页面
func (c *cHook) bindStatusHandler(s *ghttp.Server) {
//s.BindStatusHandler(400, func(r *ghttp.Request) {
// if !gstr.HasPrefix(r.URL.Path, "/400") {
// home.Error.ErrorStatusHtml(r.GetCtx(), &v1.ErrorReq{Status: "400"})
// }
//})
//s.BindStatusHandler(404, func(r *ghttp.Request) {
// if !gstr.HasPrefix(r.URL.Path, "/404") {
// home.Error.ErrorStatusHtml(r.GetCtx(), &v1.ErrorReq{Status: "404"})
// }
//})
//s.BindStatusHandler(500, func(r *ghttp.Request) {
// if !gstr.HasPrefix(r.URL.Path, "/500") {
// home.Error.ErrorStatusHtml(r.GetCtx(), &v1.ErrorReq{Status: "500"})
// }
//})
//s.BindHandler("/error/:status", func(r *ghttp.Request) {
// home.Error.ErrorStatusHtml(r.GetCtx(), &v1.ErrorReq{Status: r.Get("status").String()})
//})
//
//// HOOK, 开发阶段禁止浏览器缓存,方便调试
//if gmode.IsDevelop() {
// s.BindHookHandler("/*", ghttp.HookBeforeServe, func(r *ghttp.Request) {
// r.Response.Header().Set("Cache-Control", "no-store")
// })
//}
}
// consolePrintfHandlers 输出项目启动运行信息
func (c *cHook) consolePrintfHandlers(s *ghttp.Server) {
application := env.GetApplicationName() //启用应用名称
serverPort, _ := env.GetAddress() //服务端口
host, _ := gipv4.GetIntranetIp() //本地id
swaggerPath, _ := env.GetSwaggerPath() //swagger地址
serverPortStr := serverPort.String()
swaggerPathStr := swaggerPath.String() //swagger访问地址
//
g.Log().Infof(context.TODO(),
"\n------------------------------------------应用服务信息----------------------------------------------\n\t"+
"Application '%s' is running! Access URLs:\n\t"+
"Local: \t\t\t\t http://localhost:%s\n\t"+
"External: \t\t\t http://%s:%s\n\t"+
"Websocket: \t\t\t http://%s:%s\n\t"+
"Doc: \t\t\t\t http://%s:%s/%s/doc.html\n"+
"-----------------------------------------------------------------------------------------------------\n",
application,
serverPortStr,
host, serverPortStr,
host, serverPortStr,
host, serverPortStr, swaggerPathStr)
//如启动模式为dev则打印程序版本信息
if env.IsDev() {
versionStr := utility.GetVersionStr() //系统版本信息
g.Log().Infof(context.TODO(), "\n-----------------------------------------------------------------------------------------------------\n"+
"%s"+
"\n-----------------------------------------------------------------------------------------------------\n", versionStr)
} else {
g.Log().Infof(context.TODO(), gfile.GetContents(gfile.Pwd()+"/resource/public/html/bannar.txt"))
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。