shortener

package
v0.0.0-...-45d8196 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

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

func CreateAsset(ctx context.Context, as *types.Asset) (string, error)

CreateAsset stores an asset in the Datastore

func CreateGeoLocation

func CreateGeoLocation(ctx context.Context, ip string) error

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

func GetAsset

func GetAsset(ctx context.Context, uri string) (*types.Asset, error)

GetAsset retrieves the asset

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

func (t *AssetDS) AsExternal() *types.Asset

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

Jump to

Keyboard shortcuts

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