Make putForm more generic

This commit is contained in:
Bryan Boreham committed 2014-10-14 15:23:20 +01:00
1 parent 7f6e0a1e42
commit 9bd464a003
1 file changed
+3 -3
+3 -3
View File
@@ -11,8 +11,8 @@ import (
"time"
)
func putForm(url string, data url.Values) (resp *http.Response, err error) {
req, err := http.NewRequest("PUT", url, strings.NewReader(data.Encode()))
func genForm(method string, url string, data url.Values) (resp *http.Response, err error) {
req, err := http.NewRequest(method, url, strings.NewReader(data.Encode()))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
return http.DefaultClient.Do(req)
}
@@ -34,7 +34,7 @@ func TestHttp(t *testing.T) {
// Ask the http server to add our test address into the database
addr_parts := strings.Split(test_addr1, "/")
resp, err := putForm(fmt.Sprintf("http://localhost:%d/name/%s/%s", port, container_id, addr_parts[0]),
resp, err := genForm("PUT", fmt.Sprintf("http://localhost:%d/name/%s/%s", port, container_id, addr_parts[0]),
url.Values{"fqdn": {success_test_name}, "local_ip": {docker_ip}, "routing_prefix": {addr_parts[1]}})
if err != nil {
t.Fatal(err)