Documentation
¶
Overview ¶
Package gh is an abbreviation of gin http.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProvideMiddleware ¶
func ProvideMiddleware(fn interface{})
ProvideMiddleware provide middleware
func ProvideRouterGroup ¶
func ProvideRouterGroup(groupName string, fn interface{})
ProvideRouterGroup define a router group and inject it into the runtime, then you can use it anywhere during the project lifecyle.
First, you need to use a function to create a `gin.RouterGroup`:
func init() {
gh.ProvideRouterGroup("api", func(app *gh.App) *gin.RouterGroup {
return app.Engine.Group("api")
})
}
Then, you can use it anywhere with DI:
type routerParams struct {
fx.In
Default *gin.RouterGroup `name:"api"`
}
func init() {
di.Invoke(func(r routerParams) {
r.Default.GET("/", func(c *gin.Context) {
c.Writer.WriteString("Hello, world!")
})
})
}
Types ¶
type App ¶
App Global App
func (*App) ParseConfig ¶
ParseConfig parse `app` field in config file to an variable
Click to show internal directories.
Click to hide internal directories.