mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 12:44:10 -06:00
25 lines
472 B
Go
25 lines
472 B
Go
package middleware
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gopkg.in/macaron.v1"
|
|
|
|
m "github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/services/quota"
|
|
)
|
|
|
|
func Quota(target string) macaron.Handler {
|
|
return func(c *m.ReqContext) {
|
|
limitReached, err := quota.QuotaReached(c, target)
|
|
if err != nil {
|
|
c.JsonApiErr(500, "failed to get quota", err)
|
|
return
|
|
}
|
|
if limitReached {
|
|
c.JsonApiErr(403, fmt.Sprintf("%s Quota reached", target), nil)
|
|
return
|
|
}
|
|
}
|
|
}
|