Documentation
¶
Overview ¶
Package client is a client for downloading GeoIP2 and GeoLite2 MMDB databases.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client downloads GeoIP2 and GeoLite2 MMDB databases.
After creation, it is valid for concurrent use.
func (Client) Download ¶
Download attempts to download the edition.
The editionID parameter is a valid database edition ID, such as "GeoIP2-City".
The MD5 parameter is a string representation of the MD5 sum of the database MMDB file you have previously downloaded. If you don't yet have one downloaded, this can be "". This is used to know if an update is available and avoid consuming resources if there is not.
If the current MD5 checksum matches what the server currently has, no download is performed.
Returns an HTTPError if the server returns a non-200 status code. This can be used to identify problems with license.
type DownloadResponse ¶
type DownloadResponse struct { // LastModified is the date that the database was last modified. It will // only be set if UpdateAvailable is true. LastModified time.Time // MD5 is the string representation of the new database. It will only be set // if UpdateAvailable is true. MD5 string // Reader can be read to access the database itself. It will only contain a // database if UpdateAvailable is true. // // If the Download call does not return an error, Reader will always be // non-nil. // // If UpdateAvailable is true, the caller must read Reader to completion and // close it. Reader io.ReadCloser // UpdateAvailable is true if there is an update available for download. It // will be false if the MD5 used in the Download call matches what the server // currently has. UpdateAvailable bool }
DownloadResponse describes the result of a Download call.
type HTTPError ¶ added in v7.1.0
HTTPError is an error from performing an HTTP request and receiving a non-200 status code.
See https://dev.maxmind.com/geoip/docs/web-services/responses/#errors for more details.
type Option ¶
type Option func(*Client)
Option is an option for configuring Client.
func WithEndpoint ¶
WithEndpoint sets the base endpoint to use. By default we use https://updates.maxmind.com.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client to use. By default we use http.DefaultClient.