api

package
v0.0.0-...-62cd6ad Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Cache = cache.New(5*time.Minute, 5*time.Minute)
)

Functions

func AddCacheItem

func AddCacheItem(id string, data *model.LookupResponse) error

AddCacheItem sets an item in the cache for the given key

func GetCacheById

func GetCacheById(id string) (*model.LookupResponse, error)

GetCacheById retrieves an item from the cache for the given key

func GetEnvFilePath

func GetEnvFilePath() string

GetEnvFilePath retrieves the absolute file path of the .env file in the directory where the calling function is located. If the caller information cannot be obtained, a message will be printed to the console. The function combines the directory path and the name of the .env file using filepath.Join. Returns the absolute file path of the .env file.

func GetGeoInfo

func GetGeoInfo(ipaddress string) (model.GeoData, int)

GetGeoInfo accepts an IP Address to perform a lookup of the geolocation information of the IP Address form KeyCDNs' Geo service. This service is rate limited to a maximum of 3 calls per second.

func InitDatabase

func InitDatabase()

func Record

func Record(lookupRequest *model.LookupRequest)

Types

type CacheItem

type CacheItem []struct {
	ID   string                `json:"id"`
	Data *model.LookupResponse `json:"data"`
}

CacheItem struct holds the string key and the cached pointer of the item being cached

Jump to

Keyboard shortcuts

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