fix flareresolver url and use /v1 api path
All checks were successful
Build and publish the docker image / build (push) Successful in 58s
All checks were successful
Build and publish the docker image / build (push) Successful in 58s
Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
parent
48288da414
commit
c9d498d1f4
@ -2,6 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
@ -24,7 +25,7 @@ type response struct {
|
||||
Solution solution `json:"solution"`
|
||||
}
|
||||
|
||||
func GET(url string) ([]byte, int, http.Header, error) {
|
||||
func GET(target string) ([]byte, int, http.Header, error) {
|
||||
var (
|
||||
client *resty.Client = resty.New()
|
||||
res *resty.Response = nil
|
||||
@ -33,22 +34,24 @@ func GET(url string) ([]byte, int, http.Header, error) {
|
||||
)
|
||||
|
||||
if frurl = os.Getenv("FLARERESOLVER"); frurl == "" {
|
||||
if res, err := client.R().Get(url); err != nil {
|
||||
if res, err := client.R().Get(target); err != nil {
|
||||
return nil, 0, nil, err
|
||||
} else {
|
||||
return res.Body(), res.StatusCode(), res.Header(), nil
|
||||
}
|
||||
}
|
||||
|
||||
frurl, _ = url.JoinPath(frurl, "/v1")
|
||||
|
||||
client.R().SetHeader("Content-Type", "application/json")
|
||||
client.R().SetBody(request{
|
||||
Cmd: "request.get",
|
||||
Url: frurl,
|
||||
Url: target,
|
||||
MaxTimeout: 60000,
|
||||
})
|
||||
client.R().SetResult(&response{})
|
||||
|
||||
if res, err = client.R().Post(url); err != nil {
|
||||
if res, err = client.R().Post(frurl); err != nil {
|
||||
return nil, 0, nil, err
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user