MaxMind

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBCountry    = 0
	DBCity       = 1
	AdapterClass = "@pgo/Client/MaxMind/Adapter"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	pgo.Object
	// contains filtered or unexported fields
}

Adapter of MaxMind Client, add context support. usage: mmd := this.GetObject(MaxMind.AdapterClass).(*MaxMind.Adapter)

func (*Adapter) Construct

func (a *Adapter) Construct(componentId ...string)

func (*Adapter) GeoByIp

func (a *Adapter) GeoByIp(ip string, args ...interface{}) *Geo

get geo info by ip, optional args: db int: preferred max mind db lang string: preferred i18n language

func (*Adapter) GetClient

func (a *Adapter) GetClient() *Client

type Client

type Client struct {
	// contains filtered or unexported fields
}

MaxMind Client component, configuration: maxMind:

class: "@pgo/Client/MaxMind/Client"
countryFile: "@app/../geoip/GeoLite2-Country.mmdb"
cityFile: "@app/../geoip/GeoLite2-City.mmdb"

func (*Client) GeoByIp

func (c *Client) GeoByIp(ip string, args ...interface{}) *Geo

get geo info by ip, optional args: db int: preferred geo db lang string: preferred i18n language

func (*Client) Init

func (c *Client) Init()

func (*Client) SetCityFile

func (c *Client) SetCityFile(path string)

func (*Client) SetCountryFile

func (c *Client) SetCountryFile(path string)

type Geo

type Geo struct {
	Code      string `json:"code"`               // country/area code
	Continent string `json:"-"`                  // continent name (en)
	Country   string `json:"country,omitempty"`  // country/area name (en)
	Province  string `json:"province,omitempty"` // province name (en)
	City      string `json:"city,omitempty"`     // city name(en)

	// i18n name, default is en
	I18n struct {
		Continent string
		Country   string
		Province  string
		City      string
	} `json:"-"`
}

Geo lookup result

Jump to

Keyboard shortcuts

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