handlers

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handlers

type Handlers struct {
	PrivateNets []netip.Prefix
}

Handlers have some common functions for the http handlers

func NewHandlers

func NewHandlers() *Handlers

NewHandlers returns Handlers

func (*Handlers) NTPHandler

func (h *Handlers) NTPHandler(w http.ResponseWriter, req *http.Request)

NTPHandler implements GET /ntp/{ip}

func (*Handlers) TracerouteHandler

func (h *Handlers) TracerouteHandler(w http.ResponseWriter, req *http.Request)

GET /traceroute/{ip}

type Limiter

type Limiter interface {
	Check() bool
	Allowed() bool
	Done()
}

Limiter manages the rate limiting

type RateHandler

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

RateHandler wraps a handler in rate limiting

func NewRateHandler

func NewRateHandler(h http.Handler, limiter Limiter) *RateHandler

NewRateHandler returns h wrapped in the Limiter

func (*RateHandler) CheckQueue

func (rh *RateHandler) CheckQueue(w http.ResponseWriter, req *http.Request)

func (*RateHandler) ServeHTTP

func (rh *RateHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Server interface

func (*RateHandler) Wrap

func (rh *RateHandler) Wrap(wrapped http.HandlerFunc) http.HandlerFunc

Jump to

Keyboard shortcuts

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