Documentation ¶
Overview ¶
Package apiserver provides the freegeoip web server API, used by the freegeoip daemon tool.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultKeyMaker = KeyMakerFunc(func(r *http.Request) string { addr, _, _ := net.SplitHostPort(r.RemoteAddr) return addr })
DefaultKeyMaker is a KeyMaker that returns the client IP address from http.Request.RemoteAddr.
View Source
var Version = "3.0.7"
Version tag.
Functions ¶
func NewHandler ¶
func NewHandler(conf *HandlerConfig) http.Handler
NewHandler creates a freegeoip http handler.
Types ¶
type ConnStateFunc ¶
func ConnStateMetrics ¶
func ConnStateMetrics(g prometheus.Gauge) ConnStateFunc
type HandlerConfig ¶
type HandlerConfig struct { Prefix string Origin string PublicDir string DB *freegeoip.DB RateLimiter RateLimiter }
HandlerConfig holds configuration for freegeoip http handlers.
type KeyMakerFunc ¶
KeyMakerFunc is an adapter function for KeyMaker.
type RateLimiter ¶
type RateLimiter struct { Redis *redis.Client Max int Interval time.Duration KeyMaker KeyMaker Handler http.Handler // contains filtered or unexported fields }
A RateLimiter is an http.Handler that wraps another handler, and calls it up to a certain limit, max per interval.
func (*RateLimiter) ServeHTTP ¶
func (rl *RateLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface.
Click to show internal directories.
Click to hide internal directories.