ipapi

package
v0.0.0-...-cb310a5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetLocation gets the location for the given IP address or the
	// IP of the server if blank.
	GetLocation(ctx context.Context, ip string) (*WorldLocation, error)
	// Name provides a client name used to report health check issues.
	Name() string
	// Ping checks the client is healthy.
	Ping(ctx context.Context) error
}

Client is the ipapi client interface. It implements a simple in-memory transparent cache to avoid hitting the API too often and getting throttled (429).

func New

func New(c Doer) Client

New returns a new client for the ipapi.co API.

type Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer is an interface for making HTTP requests.

type WorldLocation

type WorldLocation struct {
	// Lat is the latitude of the location.
	Lat float64 `json:"lat"`
	// Long is the longitude of the location.
	Long float64 `json:"lon"`
	// City is the city of the location.
	City string `json:"city"`
	// Region is the region/state of the location.
	Region string `json:"region"`
	// Country is the country of the location.
	Country string `json:"country"`
}

WorldLocation represents the geographical location of an IP address.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL