Skip to content

Commit 643c6c9

Browse files
authored
fix: proxy parse url (#2297)
1 parent b201836 commit 643c6c9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

models/datasource.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/ccfos/nightingale/v6/pkg/poster"
1313
"github.com/pkg/errors"
1414
"github.com/toolkits/pkg/logger"
15-
"github.com/toolkits/pkg/net/httplib"
1615
"github.com/toolkits/pkg/str"
1716
)
1817

@@ -104,14 +103,13 @@ func (h HTTP) NewReq(reqUrl *string) (req *http.Request, err error) {
104103

105104
func (h HTTP) ParseUrl() (target *url.URL, err error) {
106105
urls := h.GetUrls()
107-
for i := 0; i < len(urls); i++ {
108-
if target, err = url.Parse(urls[i]); err != nil {
109-
continue
110-
}
106+
if len(urls) == 0 {
107+
return nil, errors.New("no urls")
108+
}
111109

112-
if _, err = httplib.Get(urls[i]).SetTimeout(time.Duration(h.Timeout) * time.Millisecond).Bytes(); err == nil {
113-
return
114-
}
110+
target, err = url.Parse(urls[0])
111+
if err != nil {
112+
return nil, err
115113
}
116114
return
117115
}

0 commit comments

Comments
 (0)