http

package
v0.0.0-...-473a772 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2020 License: BSD-3-Clause Imports: 14 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) Set

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

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"`
	CountryEU  *bool                `json:"country_eu,omitempty"`
	CountryISO string               `json:"country_iso,omitempty"`
	City       string               `json:"city,omitempty"`
	Hostname   string               `json:"hostname,omitempty"`
	Latitude   float64              `json:"latitude,omitempty"`
	Longitude  float64              `json:"longitude,omitempty"`
	ASN        string               `json:"asn,omitempty"`
	ASNOrg     string               `json:"asn_org,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
	LookupUUID func(net.IP, uint64) error
	// contains filtered or unexported fields
}

func New

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

func (*Server) CLIASNHandler

func (s *Server) CLIASNHandler(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

func (*Server) UUIDHandler

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

type UUIDResponse

type UUIDResponse struct {
	IP        net.IP `json:"ip"`
	Port      uint64 `json:"port"`
	Reachable bool   `json:"reachable"`
	Response  string `json:"response"`
}

Jump to

Keyboard shortcuts

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