插件开发


一个插件需要实现对应的三个接口,如:

  1. // Plugin as one of the key components of goAdmin has three
  2. // methods. GetRequest return all the path registered in the
  3. // plugin. GetHandler according the url and method return the
  4. // corresponding handler. InitPlugin init the plugin which do
  5. // something like init the database and set the config and register
  6. // the routes. The Plugin must implement the three methods.
  7. type Plugin interface {
  8. // 以下这两个接口内容基本是固定的,可参考后面的example插件,照写即可
  9. // 获取请求
  10. GetRequest() []context.Path
  11. // 获取控制器方法
  12. GetHandler(url, method string) context.Handlers
  13. // 初始化插件,接口框架的服务列表
  14. InitPlugin(services service.List)
  15. }

参考例子: