feat:插件注册&差分so

This commit is contained in:
songzhibin97
2021-08-21 10:48:44 +08:00
parent 513003a8bb
commit 181b3a985e
4 changed files with 44 additions and 27 deletions

View File

@@ -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)
}
}