diff options
| author | Loyalsoldier <[email protected]> | 2024-08-13 11:30:39 +0800 |
|---|---|---|
| committer | Loyalsoldier <[email protected]> | 2024-08-13 11:31:05 +0800 |
| commit | d3d84fd33727fb323eec832adf6f5897997fd84e (patch) | |
| tree | fb050cc6eda2a90862ad504e71927d8949e19fb9 /lib | |
| parent | 50ed45ced0f436f1a2817390df46f85a953af675 (diff) | |
Feat: support remote URL in maxmindGeoLite2ASNCSV & maxmindGeoLite2CountryCSV
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/common.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/common.go b/lib/common.go index a87285d5..51fd6b24 100644 --- a/lib/common.go +++ b/lib/common.go @@ -19,3 +19,16 @@ func GetRemoteURLContent(url string) ([]byte, error) { return io.ReadAll(resp.Body) } + +func GetRemoteURLReader(url string) (io.ReadCloser, error) { + resp, err := http.Get(url) + if err != nil { + return nil, err + } + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("failed to get remote content -> %s: %s", url, resp.Status) + } + + return resp.Body, nil +} |
