Add methods to get random posts and subreddits

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-07-20 21:03:57 -04:00
parent 5c376a1af4
commit 465e96353c
4 changed files with 104 additions and 1 deletions
+15
View File
@@ -125,6 +125,21 @@ func newClient(httpClient *http.Client) *Client {
httpClient = &http.Client{}
}
// todo...
// getting a random
httpClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
redirectURL := req.URL.String()
redirectURL = strings.Replace(redirectURL, "https://www.reddit.com", defaultBaseURL, 1)
reqURL, err := url.Parse(redirectURL)
if err != nil {
return err
}
req.URL = reqURL
return nil
}
baseURL, _ := url.Parse(defaultBaseURL)
tokenURL, _ := url.Parse(defaultTokenURL)