mirror of
https://github.com/gone-io/gone.git
synced 2025-01-23 01:00:23 +08:00
fix: templates of tools/gone
This commit is contained in:
parent
c0a5380829
commit
ed0a62e7bb
@ -23,9 +23,18 @@ type router struct {
|
||||
htmlTpl string `gone:"config,server.html-tpl-pattern"`
|
||||
mode string `gone:"config,server.mode,default=release"`
|
||||
|
||||
gone.Logger `gone:"*"`
|
||||
HandleProxyToGin `gone:"gone-gin-proxy"`
|
||||
}
|
||||
|
||||
type writer struct {
|
||||
write func(p []byte) (n int, err error)
|
||||
}
|
||||
|
||||
func (w writer) Write(p []byte) (n int, err error) {
|
||||
return w.write(p)
|
||||
}
|
||||
|
||||
func (r *router) AfterRevive() gone.AfterReviveError {
|
||||
gin.SetMode(r.mode)
|
||||
r.Engine = gin.New()
|
||||
@ -33,6 +42,19 @@ func (r *router) AfterRevive() gone.AfterReviveError {
|
||||
if r.htmlTpl != "" {
|
||||
r.Engine.LoadHTMLGlob(r.htmlTpl)
|
||||
}
|
||||
|
||||
gin.DefaultWriter = writer{
|
||||
write: func(p []byte) (n int, err error) {
|
||||
r.Debugf("%s", p)
|
||||
return len(p), nil
|
||||
},
|
||||
}
|
||||
gin.DefaultErrorWriter = writer{
|
||||
write: func(p []byte) (n int, err error) {
|
||||
r.Errorf("%s", p)
|
||||
return len(p), nil
|
||||
},
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,4 @@
|
||||
# 本地开发环境会读取该文件的配置
|
||||
server.env=dev
|
||||
server.env=dev
|
||||
|
||||
log.level=debug
|
@ -18,7 +18,7 @@ func NewDemoController() gone.Goner {
|
||||
type demoController struct {
|
||||
gone.Flag
|
||||
demoSvc service.IDemo `gone:"*"`
|
||||
gone.Logger `gone:"gone-logger"`
|
||||
gone.Logger `gone:"*"`
|
||||
|
||||
authRouter gone.IRouter `gone:"router-auth"`
|
||||
pubRouter gone.IRouter `gone:"router-pub"`
|
||||
|
@ -15,7 +15,7 @@ func NewAuthorizeMiddleware() gone.Goner {
|
||||
|
||||
type AuthorizeMiddleware struct {
|
||||
gone.Flag
|
||||
gone.Logger `gone:"gone-logger"`
|
||||
gone.Logger `gone:"*"`
|
||||
userKey string `gone:"config,auth.user-key"`
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ func NewPlantMiddleware() gone.Goner {
|
||||
// PubMiddleware 公共中间件
|
||||
type PubMiddleware struct {
|
||||
gone.Flag
|
||||
gone.Logger `gone:"gone-logger"`
|
||||
gone.Logger `gone:"*"`
|
||||
}
|
||||
|
||||
func (m *PubMiddleware) Next(ctx *gone.Context) (interface{}, error) {
|
||||
|
@ -13,7 +13,7 @@ func NewDb() gone.Goner {
|
||||
|
||||
type db struct {
|
||||
gone.Flag
|
||||
gone.XormEngine `gone:"gone-xorm"`
|
||||
gone.XormEngine `gone:"*"`
|
||||
}
|
||||
|
||||
func (d *db) createUser(user *entity.User) error {
|
||||
|
@ -15,7 +15,7 @@ func NewAuth() (gone.Goner, gone.GonerId) {
|
||||
type authRouter struct {
|
||||
gone.Flag
|
||||
gone.IRouter
|
||||
root gone.IRouter `gone:"gone-gin-router"`
|
||||
root gone.RouteGroup `gone:"*"`
|
||||
|
||||
auth *middleware.AuthorizeMiddleware `gone:"*"`
|
||||
pub *middleware.PubMiddleware `gone:"*"`
|
||||
|
@ -15,7 +15,7 @@ func NewPubRouter() (gone.Goner, gone.GonerId) {
|
||||
type pubRouter struct {
|
||||
gone.Flag
|
||||
gone.IRouter
|
||||
root gone.IRouter `gone:"gone-gin-router"`
|
||||
root gone.RouteGroup `gone:"*"`
|
||||
pub *middleware.PubMiddleware `gone:"*"`
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ func NewAuthorizeMiddleware() gone.Goner {
|
||||
|
||||
type AuthorizeMiddleware struct {
|
||||
gone.Flag
|
||||
gone.Logger `gone:"gone-logger"`
|
||||
gone.Logger `gone:"*"`
|
||||
userKey string `gone:"config,auth.user-key"`
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ func NewPlantMiddleware() gone.Goner {
|
||||
// PubMiddleware 公共中间件
|
||||
type PubMiddleware struct {
|
||||
gone.Flag
|
||||
gone.Logger `gone:"gone-logger"`
|
||||
gone.Logger `gone:"*"`
|
||||
}
|
||||
|
||||
func (m *PubMiddleware) Next(ctx *gone.Context) (interface{}, error) {
|
||||
|
@ -15,7 +15,7 @@ func NewAuth() (gone.Goner, gone.GonerId) {
|
||||
type authRouter struct {
|
||||
gone.Flag
|
||||
gone.IRouter
|
||||
root gone.IRouter `gone:"gone-gin-router"`
|
||||
root gone.RouteGroup `gone:"*"`
|
||||
|
||||
auth *middleware.AuthorizeMiddleware `gone:"*"`
|
||||
pub *middleware.PubMiddleware `gone:"*"`
|
||||
|
Loading…
Reference in New Issue
Block a user