Merge pull request #23 from jarylc/proxy-option-for-reddit
Added a request-url-template option for Reddit requests
This commit is contained in:
commit
5fdc3e3f10
3 changed files with 28 additions and 3 deletions
|
|
@ -30,8 +30,12 @@ type subredditResponseJson struct {
|
|||
} `json:"data"`
|
||||
}
|
||||
|
||||
func FetchSubredditPosts(subreddit string, commentsUrlTemplate string) (ForumPosts, error) {
|
||||
requestUrl := fmt.Sprintf("https://www.reddit.com/r/%s/hot.json", url.QueryEscape(subreddit))
|
||||
func FetchSubredditPosts(subreddit string, commentsUrlTemplate string, requestUrlTemplate string) (ForumPosts, error) {
|
||||
subreddit = url.QueryEscape(subreddit)
|
||||
requestUrl := fmt.Sprintf("https://www.reddit.com/r/%s/hot.json", subreddit)
|
||||
if requestUrlTemplate != "" {
|
||||
requestUrl = strings.ReplaceAll(requestUrlTemplate, "{REQUEST-URL}", requestUrl)
|
||||
}
|
||||
request, err := http.NewRequest("GET", requestUrl, nil)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue