http

package
v0.0.0-...-e82848a Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Assets embed.FS

Functions

This section is empty.

Types

type AppError

type AppError struct {
	Error       error
	Message     string
	Code        int
	ContentType string
}

func NotFoundHandler

func NotFoundHandler(_ http.ResponseWriter, r *http.Request) *AppError

func (*AppError) AsJSON

func (e *AppError) AsJSON() *AppError

func (*AppError) IsJSON

func (e *AppError) IsJSON() bool

func (*AppError) WithMessage

func (e *AppError) WithMessage(message string) *AppError

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"`
	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"`
	ReverseDNS        string               `json:"hostname,omitempty"`
	ForwardReverseDNS string               `json:"forward_reverse_dns,omitempty"`
	UserAgent         *useragent.UserAgent `json:"user_agent,omitempty"`
	Protocol          string               `json:"protocol,omitempty"`
	FRDNSMatch        bool                 `json:"frdns_match,omitempty"`
}

type Route

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

func (*Route) Header

func (r *Route) Header(header, value string)

func (*Route) MatcherFunc

func (r *Route) MatcherFunc(f func(*http.Request) bool)

type Router

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

func NewRouter

func NewRouter() *Router

func (*Router) Handler

func (r *Router) Handler() http.Handler

func (*Router) Route

func (r *Router) Route(method, path string, handler appHandler) *Route

func (*Router) RoutePrefix

func (r *Router) RoutePrefix(method, path string, handler appHandler) *Route

type Server

type Server struct {
	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