api_plugin.go 695 B

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