Skip to content

Commit

Permalink
Implementing a new initialization mode
Browse files Browse the repository at this point in the history
  • Loading branch information
acexy committed Mar 25, 2024
1 parent 50d2e84 commit 3e9f0e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
13 changes: 3 additions & 10 deletions ginmodule/ginloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ type GinModule struct {
GinModuleConfig *declaration.ModuleConfig
GinInterceptor func(instance interface{})

ginEngine *gin.Engine

// * 注册业务路由
Routers []Router

Expand Down Expand Up @@ -51,14 +49,9 @@ func (g *GinModule) ModuleConfig() *declaration.ModuleConfig {
}
}

func (g *GinModule) RawInstance() interface{} {
g.ginEngine = gin.New()
return g.ginEngine
}

func (g *GinModule) Register() error {
func (g *GinModule) Register() (interface{}, error) {
var err error
ginEngin := g.ginEngine
ginEngin := gin.New()
if g.DebugModule {
gin.SetMode(gin.DebugMode)
} else {
Expand Down Expand Up @@ -99,7 +92,7 @@ func (g *GinModule) Register() error {
}
}()

return err
return ginEngin, err
}

func (g *GinModule) Unregister(maxWaitSeconds uint) (gracefully bool, err error) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/acexy/golang-toolkit v0.0.4
github.com/gin-gonic/gin v1.9.1
github.com/golang-acexy/starter-parent v0.0.4
github.com/golang-acexy/starter-parent v0.0.5
)

require (
Expand Down
10 changes: 3 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ github.com/go-playground/validator/v10 v10.19.0 h1:ol+5Fu+cSq9JD7SoSqe04GMI92cbn
github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang-acexy/starter-parent v0.0.3 h1:LZlP2r8XLCNOmqGqA7rnptvjkH0Wh6M9N/HL2tSBBvM=
github.com/golang-acexy/starter-parent v0.0.3/go.mod h1:Ol9Gt1uRVVi1fSemTh0xeuZFcfIU+VATmPSm28ilnNk=
github.com/golang-acexy/starter-parent v0.0.4 h1:BNqp4ig2XOYt7C3B3ldq4r4gmfV3wWLibMqWRmpSerA=
github.com/golang-acexy/starter-parent v0.0.4/go.mod h1:Ol9Gt1uRVVi1fSemTh0xeuZFcfIU+VATmPSm28ilnNk=
github.com/golang-acexy/starter-parent v0.0.5 h1:WFmb3sP0yVNt44ICoDd84QeGQa9J0awKa6IareHupQM=
github.com/golang-acexy/starter-parent v0.0.5/go.mod h1:Ol9Gt1uRVVi1fSemTh0xeuZFcfIU+VATmPSm28ilnNk=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
Expand All @@ -52,8 +50,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeBAsoHo=
github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -69,8 +65,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
Expand Down

0 comments on commit 3e9f0e9

Please sign in to comment.