Last active
December 11, 2015 21:38
-
-
Save tamasd/4663364 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func get(path string, cookie *http.Cookie) *http.Response { | |
req, err := http.NewRequest("GET", BASE_PATH + path, nil) | |
if err != nil { | |
log.Fatal(err) | |
} | |
req.AddCookie(cookie) | |
resp, err := http.DefaultClient.Do(req) | |
if err != nil { | |
log.Fatal(err) | |
} | |
return resp | |
} | |
func post(path string, data string, cookie *http.Cookie, method string) *http.Response { | |
req, err := http.NewRequest(method, BASE_PATH + path, strings.NewReader(data)) | |
if err != nil { | |
log.Fatal(err) | |
} | |
req.Header.Set("Content-Type", "application/x-www-form-urlencoded") | |
if cookie != nil { | |
req.AddCookie(cookie) | |
} | |
resp, err := http.DefaultClient.Do(req) | |
if err != nil { | |
log.Fatal(err) | |
} | |
return resp | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment