Add newRequest function with common headers
This commit is contained in:
parent
2dc80b95cf
commit
c12927172f
4 changed files with 18 additions and 14 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue