Documentation ¶
Index ¶
- Constants
- func CreateAsset(ctx context.Context, as *types.Asset) (string, error)
- func CreateGeoLocation(ctx context.Context, ip string) error
- func CreateMeasurement(ctx context.Context, m *MeasurementDS) error
- func GetAsset(ctx context.Context, uri string) (*types.Asset, error)
- type AssetDS
- type GeoLocationDS
- type LocationType
- type LookupResult
- type MeasurementDS
- type ResultsType
Constants ¶
View Source
const ( // DatastoreAssets collection ASSETS DatastoreAssets string = "ASSETS" // DatastoreMeasurement collection MEASUREMENT DatastoreMeasurement string = "MEASUREMENT" // DatastoreGeoLocation collection GEO_LOCATION DatastoreGeoLocation string = "GEOLOCATION" )
Variables ¶
This section is empty.
Functions ¶
func CreateAsset ¶
CreateAsset stores an asset in the Datastore
func CreateGeoLocation ¶
CreateGeoLocation looks up the IP's geolocation if it is unknown
func CreateMeasurement ¶
func CreateMeasurement(ctx context.Context, m *MeasurementDS) error
CreateMeasurement records a link activation
Types ¶
type AssetDS ¶
type AssetDS struct { URI string `json:"uri,omitempty"` URL string `json:"url" binding:"required"` // ownership etc Owner string `json:"owner,omitempty"` SecretID string `json:"secret_id,omitempty"` // segmentation Source string `json:"source,omitempty"` Client string `json:"client,omitempty"` Affiliate string `json:"affiliate,omitempty"` Tags string `json:"tags,omitempty"` // internal metadata Created int64 `json:"-"` }
AssetDS is the interal structure used to store assets
func (*AssetDS) AsExternal ¶
AsExternal create an external representation of the asset
type GeoLocationDS ¶
type GeoLocationDS struct { IP string `json:"ip"` Host string `json:"host"` ISP string `json:"isp"` City string `json:"city"` CountryCode string `json:"country_code"` CountryName string `json:"country_name"` Latitude string `json:"latitude"` Longitude string `json:"longitude"` }
GeoLocationDS records a IP's geo location
type LocationType ¶
type LocationType struct { Text string `xml:",chardata"` IP string `xml:"ip"` Host string `xml:"host"` Isp string `xml:"isp"` City string `xml:"city"` Countrycode string `xml:"countrycode"` Countryname string `xml:"countryname"` Latitude string `xml:"latitude"` Longitude string `xml:"longitude"` }
LocationType holds the geo data
func (*LocationType) AsInternal ¶
func (r *LocationType) AsInternal() *GeoLocationDS
AsInternal converts the geolocation into the internal DS struct
type LookupResult ¶
type LookupResult struct { XMLName xml.Name `xml:"ip"` Text string `xml:",chardata"` Results ResultsType `xml:"results"` }
LookupResult is the struct returned by a lookup on geoiplookup.net
type MeasurementDS ¶
type MeasurementDS struct { URI string `json:"uri" binding:"required"` User string `json:"user" binding:"required"` IP string `json:"ip,omitempty"` UserAgent string `json:"user_agent,omitempty"` AcceptLanguage string `json:"accept_language,omitempty"` // internal metadata Created int64 `json:"-"` }
MeasurementDS records events
type ResultsType ¶
type ResultsType struct { XMLName xml.Name `xml:"results"` Text string `xml:",chardata"` Result LocationType `xml:"result"` }
ResultsType container for the location
Click to show internal directories.
Click to hide internal directories.