Version: v3.5.0+incompatible Latest Latest

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

Go to latest
Published: Apr 5, 2018 License: BSD-3-Clause Imports: 32 Imported by: 12



Package apiserver provides the freegeoip web server.



This section is empty.


View Source
var Version = "3.4.1"

Version tag.


func NewHandler

func NewHandler(c *Config) (http.Handler, error)

NewHandler creates an http handler for the freegeoip server that can be embedded in other servers.

func Run

func Run()

Run is the entrypoint for the freegeoip server.


type Config

type Config struct {
	FastOpen            bool          `envconfig:"TCP_FAST_OPEN"`
	Naggle              bool          `envconfig:"TCP_NAGGLE"`
	ServerAddr          string        `envconfig:"HTTP"`
	HTTP2               bool          `envconfig:"HTTP2"`
	HSTS                string        `envconfig:"HSTS"`
	TLSServerAddr       string        `envconfig:"HTTPS"`
	TLSCertFile         string        `envconfig:"CERT"`
	TLSKeyFile          string        `envconfig:"KEY"`
	LetsEncrypt         bool          `envconfig:"LETSENCRYPT"`
	LetsEncryptCacheDir string        `envconfig:"LETSENCRYPT_CACHE_DIR"`
	LetsEncryptEmail    string        `envconfig:"LETSENCRYPT_EMAIL"`
	LetsEncryptHosts    string        `envconfig:"LETSENCRYPT_HOSTS"`
	APIPrefix           string        `envconfig:"API_PREFIX"`
	CORSOrigin          string        `envconfig:"CORS_ORIGIN"`
	ReadTimeout         time.Duration `envconfig:"READ_TIMEOUT"`
	WriteTimeout        time.Duration `envconfig:"WRITE_TIMEOUT"`
	PublicDir           string        `envconfig:"PUBLIC"`
	DB                  string        `envconfig:"DB"`
	UpdateInterval      time.Duration `envconfig:"UPDATE_INTERVAL"`
	RetryInterval       time.Duration `envconfig:"RETRY_INTERVAL"`
	UseXForwardedFor    bool          `envconfig:"USE_X_FORWARDED_FOR"`
	Silent              bool          `envconfig:"SILENT"`
	LogToStdout         bool          `envconfig:"LOGTOSTDOUT"`
	LogTimestamp        bool          `envconfig:"LOGTIMESTAMP"`
	RedisAddr           string        `envconfig:"REDIS"`
	RedisTimeout        time.Duration `envconfig:"REDIS_TIMEOUT"`
	MemcacheAddr        string        `envconfig:"MEMCACHE"`
	MemcacheTimeout     time.Duration `envconfig:"MEMCACHE_TIMEOUT"`
	RateLimitBackend    string        `envconfig:"QUOTA_BACKEND"`
	RateLimitLimit      uint64        `envconfig:"QUOTA_MAX"`
	RateLimitInterval   time.Duration `envconfig:"QUOTA_INTERVAL"`
	InternalServerAddr  string        `envconfig:"INTERNAL_SERVER"`
	UpdatesHost         string        `envconfig:"UPDATES_HOST"`
	LicenseKey          string        `envconfig:"LICENSE_KEY"`
	UserID              string        `envconfig:"USER_ID"`
	ProductID           string        `envconfig:"PRODUCT_ID"`
	NewrelicName        string        `envconfig:"NEWRELIC_NAME"`
	NewrelicKey         string        `envconfig:"NEWRELIC_KEY"`
	// contains filtered or unexported fields

Config is the configuration of the freegeoip server.

func NewConfig

func NewConfig() *Config

NewConfig creates and initializes a new Config with default values.

func (*Config) AddFlags

func (c *Config) AddFlags(fs *flag.FlagSet)

AddFlags adds configuration flags to the given FlagSet.

Jump to

Keyboard shortcuts

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