Plugins: Add support for HTTP logger (#46578)

This commit is contained in:
Todd Treece
2022-07-21 09:46:47 -04:00
committed by GitHub
parent 565430f297
commit b5d57c45e3
7 changed files with 163 additions and 1 deletions
@@ -1,6 +1,8 @@
package httpclientprovider
import (
"bytes"
"io/ioutil"
"net/http"
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
@@ -13,6 +15,10 @@ type testContext struct {
func (c *testContext) createRoundTripper(name string) http.RoundTripper {
return httpclient.RoundTripperFunc(func(req *http.Request) (*http.Response, error) {
c.callChain = append(c.callChain, name)
return &http.Response{StatusCode: http.StatusOK, Request: req}, nil
return &http.Response{
StatusCode: http.StatusOK,
Request: req,
Body: ioutil.NopCloser(bytes.NewBufferString("")),
}, nil
})
}