api_plugin.go 684 B

123456789101112131415161718192021222324252627282930
  1. package plugins
  2. import (
  3. "encoding/json"
  4. "github.com/grafana/grafana/pkg/models"
  5. )
  6. type ApiPluginRoute struct {
  7. Path string `json:"path"`
  8. Method string `json:"method"`
  9. ReqSignedIn bool `json:"reqSignedIn"`
  10. ReqGrafanaAdmin bool `json:"reqGrafanaAdmin"`
  11. ReqRole models.RoleType `json:"reqRole"`
  12. Url string `json:"url"`
  13. }
  14. type ApiPlugin struct {
  15. PluginBase
  16. Routes []*ApiPluginRoute `json:"routes"`
  17. }
  18. func (app *ApiPlugin) Load(decoder *json.Decoder, pluginDir string) error {
  19. if err := decoder.Decode(&app); err != nil {
  20. return err
  21. }
  22. ApiPlugins[app.Id] = app
  23. return nil
  24. }