diff --git a/pkg/geoip/README.md b/pkg/geoip/README.md index e7cc69ec5..2e03744ce 100644 --- a/pkg/geoip/README.md +++ b/pkg/geoip/README.md @@ -1,22 +1,26 @@ -# Geoip module +# Geoip Module -This module is used to get information about the geographical location of an IPv4 or IPv6 address. +The `geoip` module provides a simple way to determine the geographical location of an IPv4 or IPv6 address. +This includes details such as longitude, latitude, country, city, and continent. +## Features -## Usage - -To get the location of the system calling this function, use exported method `Fetch` from the package `geoip` +- **Failover Mechanism:** The module attempts to fetch location data from multiple services to ensure high availability. If one URL fails, it logs the error and retries with the next URL. +- **Structured Location Data:** Returns structured data in a `Location` struct for easy integration. -1. use `geoip.Fetch()`: +```go +type Location struct { + Longitude float64 `json:"longitude"` + Latitude float64 `json:"latitude"` + Continent string `json:"continent"` + Country string `json:"country_name"` + CountryCode string `json:"country_code"` + City string `json:"city_name"` +} +``` - This method uses 3 paths of geoip, It starts with first path of `geoipURLs` if any error was produced it continues and tries out the next path, REturnes the default unknown location and the error in case it couldn't receive correct response from all paths. - -## Tests +## Usage -`geoip_test.go` tests the driver function `getLocation` which is called by the exported function `Fetch` -It mainly tests and validates: -1. Correct response. -2. Wrong response code. -3. Wrong response body. +The module provides a single exported function: `Fetch`. -#### Remark : Tests are computed on all 3 paths of `geoipURLs` to ensure correctness. \ No newline at end of file +The `Fetch` function retrieves the geographical location of the system calling the function.