Add newRequest function with common headers

This commit is contained in:
Alexander Sheiko 2020-06-15 11:59:30 +03:00
parent 2dc80b95cf
commit c12927172f
4 changed files with 18 additions and 14 deletions

View file

@ -31,14 +31,11 @@ type Profile struct {
func GetProfile(username string) (Profile, error) {
url := "https://twitter.com/" + username
req, err := http.NewRequest("GET", url, nil)
req, err := newRequest(url)
if err != nil {
return Profile{}, err
}
req.Header.Set("Accept-Language", "en-US")
req.Header.Set("X-Requested-With", "XMLHttpRequest")
resp, err := http.DefaultClient.Do(req)
if resp == nil {
return Profile{}, err