apiserver

package
v0.0.0-...-1826709 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: BSD-3-Clause Imports: 32 Imported by: 1

Documentation

Overview

Package apiserver provides the freegeoip web server.

Index

Constants

This section is empty.

Variables

View Source
var Version = "3.4.1"

Version tag.

Functions

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.

Types

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