Like Prometheus, but for logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
loki/pkg/compactor/deletion/tenant_request_handler.go

31 lines
633 B

package deletion
import (
"net/http"
"github.com/grafana/dskit/tenant"
)
func TenantMiddleware(limits Limits, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
userID, err := tenant.TenantID(ctx)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
hasDelete, err := validDeletionLimit(limits, userID)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
if !hasDelete {
http.Error(w, deletionNotAvailableMsg, http.StatusForbidden)
return
}
next.ServeHTTP(w, r)
})
}