Add: Server location latitude and longitude
This commit is contained in:
+2524
File diff suppressed because it is too large
Load Diff
+15
-7
@@ -74,6 +74,12 @@ func GetRegionByIp(ip string) (*GeoLocationResponse, error) {
|
||||
if response.Country == "" {
|
||||
continue
|
||||
}
|
||||
response.LatitudeCenter, response.LongitudeCenter, _ = GetCapitalCoordinates(fmt.Sprintf("%s,%s", response.Country, response.City))
|
||||
if response.LatitudeCenter == "" || response.LongitudeCenter == "" {
|
||||
response.LatitudeCenter = response.Latitude
|
||||
response.LongitudeCenter = response.Longitude
|
||||
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
}
|
||||
@@ -181,11 +187,13 @@ func decompressResponse(resp *http.Response) ([]byte, error) {
|
||||
|
||||
// GeoLocationResponse represents the geolocation data returned by the API.
|
||||
type GeoLocationResponse struct {
|
||||
Country string `json:"country"`
|
||||
CountryName string `json:"country_name"`
|
||||
Region string `json:"region"`
|
||||
City string `json:"city"`
|
||||
Latitude string `json:"latitude"`
|
||||
Longitude string `json:"longitude"`
|
||||
Loc string `json:"loc"`
|
||||
Country string `json:"country"`
|
||||
CountryName string `json:"country_name"`
|
||||
Region string `json:"region"`
|
||||
City string `json:"city"`
|
||||
Latitude string `json:"latitude"`
|
||||
Longitude string `json:"longitude"`
|
||||
LatitudeCenter string `json:"latitude_center"`
|
||||
LongitudeCenter string `json:"longitude_center"`
|
||||
Loc string `json:"loc"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user