MCPcopy Create free account
hub / github.com/evcc-io/evcc / request

Method request

plugin/http.go:203–225  ·  view source on GitHub ↗

request executes the configured request or returns the cached value

(url string, body string)

Source from the content-addressed store, hash-verified

201
202// request executes the configured request or returns the cached value
203func (p *HTTP) request(url string, body string) ([]byte, error) {
204 var b io.Reader
205 if p.method != http.MethodGet {
206 b = strings.NewReader(body)
207 }
208
209 url = util.DefaultScheme(url, "http")
210
211 // empty method becomes GET
212 req, err := request.New(p.method, url, b, p.headers)
213 if err != nil {
214 return []byte{}, err
215 }
216
217 val, err := p.DoBody(req)
218 if err != nil {
219 if err2 := knownErrors(val); err2 != nil {
220 err = err2
221 }
222 }
223
224 return val, err
225}
226
227var _ Getters = (*HTTP)(nil)
228

Callers 3

StringGetterMethod · 0.95
setMethod · 0.95
simulatorApplyFunction · 0.45

Calls 4

DefaultSchemeFunction · 0.92
NewFunction · 0.92
knownErrorsFunction · 0.85
DoBodyMethod · 0.80

Tested by

no test coverage detected