feat:插件注册&差分so
This commit is contained in:
@@ -1,16 +1,31 @@
|
||||
package example
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
import (
|
||||
"gin-vue-admin/utils/plugin"
|
||||
|
||||
type Plugin struct {
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var Plugin []plugin.Plugin = []plugin.Plugin{&PluginExample}
|
||||
|
||||
var PluginExample = pluginExample{}
|
||||
|
||||
type pluginExample struct {
|
||||
}
|
||||
|
||||
func (*Plugin) Register(group *gin.RouterGroup) {
|
||||
func (*pluginExample) Register(group *gin.RouterGroup) {
|
||||
group.GET("hello", func(context *gin.Context) {
|
||||
context.JSON(200, "hello world")
|
||||
})
|
||||
}
|
||||
|
||||
func (*Plugin) RouterPath() string {
|
||||
func (*pluginExample) RouterPath() string {
|
||||
return "group"
|
||||
}
|
||||
|
||||
func PluginInit(group *gin.RouterGroup) {
|
||||
for i := range Plugin {
|
||||
PluginGroup := group.Group(Plugin[i].RouterPath())
|
||||
Plugin[i].Register(PluginGroup)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user