handler

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAPIKeyValidation added in v0.2.12

func WithAPIKeyValidation(validator APIKeyValidator, next http.HandlerFunc) http.HandlerFunc

WithAPIKeyValidation creates middleware that validates API keys and adds org info to context.

Types

type APIKeyValidator added in v0.2.12

type APIKeyValidator interface {
	// ValidateKey validates the provided API key and returns the associated
	// organization name if valid. Returns an error if the key is invalid.
	ValidateKey(ctx context.Context, key string) (string, error)
}

APIKeyValidator is an interface for validating API keys and retrieving associated organization info.

type ASNFinder

type ASNFinder interface {
	AnnotateIP(src string) *annotator.Network
	Reload(ctx context.Context)
}

ASNFinder is an interface used by the Server to manage ASN information.

type DNSTracker added in v0.2.0

type DNSTracker interface {
	Update(string, []string) error
	Delete(string) error
	List() ([]string, [][]string, error)
}

type Datastore added in v0.2.13

type Datastore interface {
	GetOrganization(ctx context.Context, name string) (*adminx.Organization, error)
}

type IataFinder

type IataFinder interface {
	Lookup(country string, lat, lon float64) (string, error)
	Find(iata string) (iata.Row, error)
	Load(ctx context.Context) error
}

IataFinder is an interface used by the Server to manage IATA information.

type MaxmindFinder

type MaxmindFinder interface {
	City(ip net.IP) (*geoip2.City, error)
	Reload(ctx context.Context) error
}

MaxmindFinder is an interface used by the Server to manage Maxmind information.

type Server

type Server struct {
	Project string
	Iata    IataFinder
	Maxmind MaxmindFinder
	ASN     ASNFinder
	DNS     dnsiface.Service
	// contains filtered or unexported fields
}

Server maintains shared state for the server.

func NewServer

func NewServer(project string, finder IataFinder, maxmind MaxmindFinder, asn ASNFinder,
	ds dnsiface.Service, tracker DNSTracker, sm ServiceAccountSecretManager, dsm Datastore,
	minVersion string) *Server

NewServer creates a new Server instance for request handling.

func (*Server) Delete

func (s *Server) Delete(rw http.ResponseWriter, req *http.Request)

Delete handler is used by operators to delete a previously registered hostname from DNS.

func (*Server) List added in v0.2.0

func (s *Server) List(rw http.ResponseWriter, req *http.Request)

List handler is used by monitoring to generate a list of known, active hostnames previously registered with the Autojoin API.

func (*Server) Live

func (s *Server) Live(rw http.ResponseWriter, req *http.Request)

Live reports whether the system is live.

func (*Server) Lookup

func (s *Server) Lookup(rw http.ResponseWriter, req *http.Request)

Lookup is a handler used to find the nearest IATA given client IP or lat/lon metadata.

func (*Server) Ready

func (s *Server) Ready(rw http.ResponseWriter, req *http.Request)

Ready reports whether the server is ready.

func (*Server) Register

func (s *Server) Register(rw http.ResponseWriter, req *http.Request)

Register handler is used by autonodes to register their hostname with M-Lab on startup and receive additional needed configuration metadata.

func (*Server) Reload

func (s *Server) Reload(ctx context.Context)

Reload reloads all resources used by the Server.

type ServiceAccountSecretManager added in v0.2.3

type ServiceAccountSecretManager interface {
	LoadOrCreateKey(ctx context.Context, org string) (string, error)
}

ServiceAccountSecretManager is an interface used by the server to allocate service account keys.

Jump to

Keyboard shortcuts

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