mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
27 lines
659 B
Go
27 lines
659 B
Go
package hooks
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/api/dtos"
|
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
|
)
|
|
|
|
type IndexDataHook func(indexData *dtos.IndexViewData, req *contextmodel.ReqContext)
|
|
|
|
type HooksService struct {
|
|
indexDataHooks []IndexDataHook
|
|
}
|
|
|
|
func ProvideService() *HooksService {
|
|
return &HooksService{}
|
|
}
|
|
|
|
func (srv *HooksService) AddIndexDataHook(hook IndexDataHook) {
|
|
srv.indexDataHooks = append(srv.indexDataHooks, hook)
|
|
}
|
|
|
|
func (srv *HooksService) RunIndexDataHooks(indexData *dtos.IndexViewData, req *contextmodel.ReqContext) {
|
|
for _, hook := range srv.indexDataHooks {
|
|
hook(indexData, req)
|
|
}
|
|
}
|