firebase.go
func (f *f) Call(method, path, auth string, body []byte, params map[string]string) ([]byte, error) {
	if !strings.HasSuffix(path, "/") {
		path += "/"
	}

	path += suffix
	qs := url.Values{}

	// if the client has an auth, set it as a query string.
	// the caller can also override this on a per-call basis
	// which will happen via params below
	if len(auth) > 0 {
		qs.Set("auth", auth)
	}

	for k, v := range params {
		qs.Set(k, v)
	}

	if len(qs) > 0 {
		path += "?" + qs.Encode()
	}

	req, err := http.NewRequest(method, path, bytes.NewReader(body))
	if err != nil {
		log.Printf("Cannot create Firebase request: %v\n", err)
		return nil, err
	}

	req.Close = true
	log.Printf("Calling %v %q\n", method, path)

	res, err := httpClient.Do(req)
	if err != nil {
		log.Printf("Request to Firebase failed: %v\n", err)
		return nil, err
	}
	defer res.Body.Close()

	ret, err := ioutil.ReadAll(res.Body)
	if err != nil {
		log.Printf("Cannot parse Firebase response: %v\n", err)
		return nil, err
	}

	if res.StatusCode >= 400 {
		err = errors.New(string(ret))
		log.Printf("Error encountered from Firebase: %v\n", err)
		return nil, err
	}

	return ret, nil
}
func (f *f) Call(method, path, auth string, body []byte, params map[string]string) ([]byte, error) {
	if !strings.HasSuffix(path, "/") {
		path += "/"
	}

	path += suffix
	qs := url.Values{}

	// if the client has an auth, set it as a query string.
	// the caller can also override this on a per-call basis
	// which will happen via params below
	if len(auth) > 0 {
		qs.Set("auth", auth)
	}

	for k, v := range params {
		qs.Set(k, v)
	}

	if len(qs) > 0 {
		path += "?" + qs.Encode()
	}

	req, err := http.NewRequest(method, path, bytes.NewReader(body))
	if err != nil {
		log.Printf("Cannot create Firebase request: %v\n", err)
		return nil, err
	}

	req.Close = true
	log.Printf("Calling %v %q\n", method, path)

	res, err := httpClient.Do(req)
	if err != nil {
		log.Printf("Request to Firebase failed: %v\n", err)
		return nil, err
	}
	defer res.Body.Close()

	ret, err := ioutil.ReadAll(res.Body)
	if err != nil {
		log.Printf("Cannot parse Firebase response: %v\n", err)
		return nil, err
	}

	if res.StatusCode >= 400 {
		err = errors.New(string(ret))
		log.Printf("Error encountered from Firebase: %v\n", err)
		return nil, err
	}

	return ret, nil
}
// Call invokes the appropriate HTTP method on a given Firebase URL.