attempt to add flareresolver support
All checks were successful
Build and publish the docker image / build (push) Successful in 1m4s
All checks were successful
Build and publish the docker image / build (push) Successful in 1m4s
Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
parent
ed37cc6af6
commit
4e8606c44a
@ -51,8 +51,25 @@ func GetImage(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// download the image
|
// download the image
|
||||||
|
var resp *resty.Response = nil
|
||||||
client := resty.New()
|
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 {
|
if err != nil {
|
||||||
c.AbortWithStatus(500)
|
c.AbortWithStatus(500)
|
||||||
return
|
return
|
||||||
|
@ -156,10 +156,26 @@ func parseAndValidateParameters(c *gin.Context) (inputs viewQuestionInputs, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fetchQuestionData sends the request to StackOverflow.
|
// 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()
|
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.
|
// extractQuestionData parses the HTML document and extracts question data.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user