diff --git a/src/routes/image.go b/src/routes/image.go index a070985..252b12d 100644 --- a/src/routes/image.go +++ b/src/routes/image.go @@ -51,8 +51,25 @@ func GetImage(c *gin.Context) { } // download the image + var resp *resty.Response = nil client := resty.New() - resp, err := client.R().Get(claims.ImageURL) + + if flareurl := os.Getenv("FLARERESOLVER"); flareurl == "" { + resp, err = client.R().Get(claims.ImageURL) + } else { + client.R().SetHeader("Content-Type", "application/json") + client.R().SetBody(struct { + Cmd string `json:"cmd"` + Url string `json:"url"` + MaxTimeout int `json:"maxTimeout"` + }{ + Cmd: "request.get", + Url: claims.ImageURL, + MaxTimeout: 60000, + }) + resp, err = client.R().Post(claims.ImageURL) + } + if err != nil { c.AbortWithStatus(500) return diff --git a/src/routes/question.go b/src/routes/question.go index 3b6274b..e921215 100644 --- a/src/routes/question.go +++ b/src/routes/question.go @@ -156,10 +156,26 @@ func parseAndValidateParameters(c *gin.Context) (inputs viewQuestionInputs, err } // fetchQuestionData sends the request to StackOverflow. -func fetchQuestionData(soLink string) (resp *resty.Response, err error) { +func fetchQuestionData(soLink string) (*resty.Response, error) { + flareurl := "" client := resty.New() - resp, err = client.R().Get(soLink) - return + + if flareurl = os.Getenv("FLARERESOLVER"); flareurl == "" { + return client.R().Get(soLink) + } + + client.R().SetHeader("Content-Type", "application/json") + client.R().SetBody(struct { + Cmd string `json:"cmd"` + Url string `json:"url"` + MaxTimeout int `json:"maxTimeout"` + }{ + Cmd: "request.get", + Url: soLink, + MaxTimeout: 60000, + }) + + return client.R().Post(flareurl) } // extractQuestionData parses the HTML document and extracts question data. diff --git a/src/utils/links.go b/src/utils/links.go index 56ad79a..6d9d8d7 100644 --- a/src/utils/links.go +++ b/src/utils/links.go @@ -42,4 +42,4 @@ func ReplaceStackOverflowLinks(html string) string { // Replace the href attribute value in the anchor tag return strings.Replace(match, hrefMatch[1], newUrl, 1) }) -} \ No newline at end of file +}