func()

in backends/backends.go [115:133]


func (b *Backend) Patch(path string, body []byte) ([]byte, error) {
	r, err := http.NewRequest(http.MethodPatch, path, bytes.NewReader(body))
	if err != nil {
		return nil, fmt.Errorf("failure sending a backend create request: %w", err)
	}
	b.generateXSRFToken(r)
	rr := httptest.NewRecorder()
	b.handler.ServeHTTP(rr, r)
	resp := rr.Result()
	respBytes, err := ioutil.ReadAll(resp.Body)
	resp.Body.Close()
	if err != nil {
		return nil, fmt.Errorf("failure reading the backend create response: %w", err)
	}
	if resp.StatusCode != http.StatusOK {
		return nil, fmt.Errorf("%w: %s", util.HTTPError(resp.StatusCode), string(respBytes))
	}
	return respBytes, nil
}