github.com/kotovmak/go-admin@v1.1.1/plugins/example/go_plugin/main.go (about) 1 package main 2 3 import ( 4 "github.com/kotovmak/go-admin/context" 5 "github.com/kotovmak/go-admin/modules/auth" 6 c "github.com/kotovmak/go-admin/modules/config" 7 "github.com/kotovmak/go-admin/modules/db" 8 "github.com/kotovmak/go-admin/modules/service" 9 "github.com/kotovmak/go-admin/plugins" 10 ) 11 12 type Example struct { 13 *plugins.Base 14 } 15 16 var Plugin = &Example{ 17 Base: &plugins.Base{PlugName: "example"}, 18 } 19 20 func (example *Example) InitPlugin(srv service.List) { 21 example.InitBase(srv, "example") 22 Plugin.App = example.initRouter(c.Prefix(), srv) 23 } 24 25 func (example *Example) initRouter(prefix string, srv service.List) *context.App { 26 27 app := context.NewApp() 28 route := app.Group(prefix) 29 route.GET("/example", auth.Middleware(db.GetConnection(srv)), example.TestHandler) 30 31 return app 32 } 33 34 func (example *Example) TestHandler(ctx *context.Context) { 35 36 }