mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Docs: Update backend plugin forwarding of headers (#67913)
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com> Co-authored-by: Joseph Perez <45749060+josmperez@users.noreply.github.com>
This commit is contained in:
parent
b8093bd0d9
commit
04df92ab47
@ -291,7 +291,7 @@ To allow Grafana to pass the access token to the plugin, update the data source
|
||||
|
||||
When configured, Grafana can forward authorization HTTP headers such as `Authorization` or `X-ID-Token` to a backend data source. This information is available across the `QueryData`, `CallResource` and `CheckHealth` requests.
|
||||
|
||||
To get Grafana to forward the headers, create a HTTP client using the [Grafana Plugin SDK](https://pkg.go.dev/github.com/grafana/grafana-plugin-sdk-go/backend/httpclient). This package exposes request information which can be subsequently forwarded downstream and/or used directly within the plugin.
|
||||
To get Grafana to forward the headers, create a HTTP client using the [Grafana plugin SDK for Go](https://pkg.go.dev/github.com/grafana/grafana-plugin-sdk-go/backend/httpclient) and set the `ForwardHTTPHeaders` option to `true` (by default, it's set to `false`). This package exposes request information which can be subsequently forwarded downstream and/or used directly within the plugin.
|
||||
|
||||
```go
|
||||
func NewDatasource(settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
|
||||
@ -299,6 +299,9 @@ func NewDatasource(settings backend.DataSourceInstanceSettings) (instancemgmt.In
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("http client options: %w", err)
|
||||
}
|
||||
|
||||
opts.ForwardHTTPHeaders = true
|
||||
|
||||
// Important to reuse the same client for each query, to avoid using all available connections on a host
|
||||
cl, err := httpclient.New(opts)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user