handler

package
v0.0.0-...-e616b43 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_SIZE_DEFAULT = 5242880 // in bytes, 5MB
	ACCESS_DENIED    = `{"error":"access denied", "success":false}`
	NOT_IMPLEMENTED  = `{"error":"not implemented", "success":false}`
	ENTRY_NOT_FOUND  = `{"error":"entry not found", "success":false}`
	REQUEST_WEIRD    = `{"error":"request too weird", "success":false}`
	CHILL_OUT        = `{"error":"you need to chill out", "success":false}`
	OOOPS            = `{"error":"we messed up on our end", "success":false}`
	SUCCESS          = `{"success":true, "size":%d, "entry":%q}`
	FAILURE          = `{"error":%q, "success":false}`
)
View Source
const (
	RATEMAX   = 1
	RATEBURST = 3
)

Variables

This section is empty.

Functions

func DeterminePeer

func DeterminePeer(config storage.Config, r *http.Request) string

func GetFile

func GetFile(eg storage.EntryGetter, config storage.Config) http.HandlerFunc

func GetList

func GetList(eg storage.PileGetter, config storage.Config, limiter *RateLimiter) http.HandlerFunc

func HasBearerToken

func HasBearerToken(token string, r *http.Request) bool

func PostFile

func PostFile(ec storage.EntryCreator, config storage.Config, limiter *RateLimiter) http.HandlerFunc

func SendFailure

func SendFailure(w http.ResponseWriter, statusCode int, problem string)

func SendMessage

func SendMessage(w http.ResponseWriter, statusCode int, messge string)

Types

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter() *RateLimiter

func (*RateLimiter) Allow

func (rl *RateLimiter) Allow(addr string) bool

type Visitor

type Visitor struct {
	Limiter  *rate.Limiter
	LastSeen time.Time
}

Jump to

Keyboard shortcuts

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