Example #1
0
func (self Client) request(method string, p string, hdrs http.Header, vals http.Values) (req *http.Request) {
	req = &http.Request{
		Method: method,
		Host:   self.RootURL.Host,
		URL:    &http.URL{Path: path.Join(self.RootURL.Path, p)},
		Header: hdrs,
	}
	if method == "GET" {
		req.URL.RawQuery = vals.Encode()
	}
	// TODO: Deletes?
	if method == "POST" || method == "PUT" {
		req.Header.Set("X-Riak-ClientId", self.ClientId)
	}
	return
}
Example #2
0
// Constructs a basic http.Request based off of a fully-qualified URL
func NewRequest(url *http.URL, method string, hdrs http.Header, params http.Values) (req *http.Request) {
	req = &http.Request{
		Method: method,
		URL: &http.URL{
			Path:     url.Path,
			RawQuery: url.RawQuery,
		},
		Host:   url.Host,
		Header: hdrs,
		Form:   params,
	}
	if req.URL.RawQuery != "" {
		req.URL.RawQuery += "&"
	}
	req.URL.RawQuery += params.Encode()
	return
}