http

package
v0.0.0-...-4b5a9b6 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouter

func NewRouter() *router

func NotFoundHandler

func NotFoundHandler(w http.ResponseWriter, r *http.Request) *appError

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache(capacity int) *Cache

func (*Cache) Get

func (c *Cache) Get(ip net.IP) (Response, bool)

func (*Cache) Resize

func (c *Cache) Resize(capacity int) error

func (*Cache) Set

func (c *Cache) Set(ip net.IP, resp Response)

func (*Cache) Stats

func (c *Cache) Stats() CacheStats

type CacheStats

type CacheStats struct {
	Capacity  int
	Size      int
	Evictions uint64
}

type PortResponse

type PortResponse struct {
	IP        net.IP `json:"ip"`
	Port      uint64 `json:"port"`
	Reachable bool   `json:"reachable"`
}

type Response

type Response struct {
	IP         net.IP               `json:"ip"`
	IPDecimal  *big.Int             `json:"ip_decimal"`
	Country    string               `json:"country,omitempty"`
	CountryISO string               `json:"country_iso,omitempty"`
	CountryEU  *bool                `json:"country_eu,omitempty"`
	RegionName string               `json:"region_name,omitempty"`
	RegionCode string               `json:"region_code,omitempty"`
	MetroCode  uint                 `json:"metro_code,omitempty"`
	PostalCode string               `json:"zip_code,omitempty"`
	City       string               `json:"city,omitempty"`
	Latitude   float64              `json:"latitude,omitempty"`
	Longitude  float64              `json:"longitude,omitempty"`
	Timezone   string               `json:"time_zone,omitempty"`
	ASN        string               `json:"asn,omitempty"`
	ASNOrg     string               `json:"asn_org,omitempty"`
	Hostname   string               `json:"hostname,omitempty"`
	UserAgent  *useragent.UserAgent `json:"user_agent,omitempty"`
}

type Server

type Server struct {
	Template   string
	IPHeaders  []string
	LookupAddr func(net.IP) (string, error)
	LookupPort func(net.IP, uint64) error

	Sponsor bool
	// contains filtered or unexported fields
}

func New

func New(db geo.Reader, cache *Cache, profile bool) *Server

func (*Server) CLIASNHandler

func (s *Server) CLIASNHandler(w http.ResponseWriter, r *http.Request) *appError

func (*Server) CLIASNOrgHandler

func (s *Server) CLIASNOrgHandler(w http.ResponseWriter, r *http.Request) *appError

func (*Server) CLICityHandler

func (s *Server) CLICityHandler(w http.ResponseWriter, r *http.Request) *appError

func (*Server) CLICoordinatesHandler

func (s *Server) CLICoordinatesHandler(w http.ResponseWriter, r *http.Request) *appError

func (*Server) CLICountryHandler

func (s *Server) CLICountryHandler(w http.ResponseWriter, r *http.Request) *appError

func (*Server) CLICountryISOHandler

func (s *Server) CLICountryISOHandler(w http.ResponseWriter, r *http.Request) *appError

func (*Server) CLIHandler

func (s *Server) CLIHandler(w http.ResponseWriter, r *http.Request) *appError

func (*Server) DefaultHandler

func (s *Server) DefaultHandler(w http.ResponseWriter, r *http.Request) *appError

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) HealthHandler

func (s *Server) HealthHandler(w http.ResponseWriter, r *http.Request) *appError

func (*Server) JSONHandler

func (s *Server) JSONHandler(w http.ResponseWriter, r *http.Request) *appError

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

func (*Server) PortHandler

func (s *Server) PortHandler(w http.ResponseWriter, r *http.Request) *appError

Jump to

Keyboard shortcuts

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