mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 16:42:36 +08:00
Plugins: Add baseMiddleware support (#87799)
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/services/auth/identity"
|
||||
"github.com/grafana/grafana/pkg/services/contexthandler"
|
||||
@ -15,13 +16,15 @@ import (
|
||||
func NewUserHeaderMiddleware() plugins.ClientMiddleware {
|
||||
return plugins.ClientMiddlewareFunc(func(next plugins.Client) plugins.Client {
|
||||
return &UserHeaderMiddleware{
|
||||
next: next,
|
||||
baseMiddleware: baseMiddleware{
|
||||
next: next,
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type UserHeaderMiddleware struct {
|
||||
next plugins.Client
|
||||
baseMiddleware
|
||||
}
|
||||
|
||||
func (m *UserHeaderMiddleware) applyUserHeader(ctx context.Context, h backend.ForwardHTTPHeaders) {
|
||||
@ -67,19 +70,3 @@ func (m *UserHeaderMiddleware) CheckHealth(ctx context.Context, req *backend.Che
|
||||
|
||||
return m.next.CheckHealth(ctx, req)
|
||||
}
|
||||
|
||||
func (m *UserHeaderMiddleware) CollectMetrics(ctx context.Context, req *backend.CollectMetricsRequest) (*backend.CollectMetricsResult, error) {
|
||||
return m.next.CollectMetrics(ctx, req)
|
||||
}
|
||||
|
||||
func (m *UserHeaderMiddleware) SubscribeStream(ctx context.Context, req *backend.SubscribeStreamRequest) (*backend.SubscribeStreamResponse, error) {
|
||||
return m.next.SubscribeStream(ctx, req)
|
||||
}
|
||||
|
||||
func (m *UserHeaderMiddleware) PublishStream(ctx context.Context, req *backend.PublishStreamRequest) (*backend.PublishStreamResponse, error) {
|
||||
return m.next.PublishStream(ctx, req)
|
||||
}
|
||||
|
||||
func (m *UserHeaderMiddleware) RunStream(ctx context.Context, req *backend.RunStreamRequest, sender *backend.StreamSender) error {
|
||||
return m.next.RunStream(ctx, req, sender)
|
||||
}
|
||||
|
Reference in New Issue
Block a user