Documentation ¶
Index ¶
- Constants
- func DeterminePeer(config storage.Config, r *http.Request) string
- func GetFile(eg storage.EntryGetter, config storage.Config) http.HandlerFunc
- func GetList(eg storage.PileGetter, config storage.Config, limiter *RateLimiter) http.HandlerFunc
- func HasBearerToken(token string, r *http.Request) bool
- func PostFile(ec storage.EntryCreator, config storage.Config, limiter *RateLimiter) http.HandlerFunc
- func SendFailure(w http.ResponseWriter, statusCode int, problem string)
- func SendMessage(w http.ResponseWriter, statusCode int, messge string)
- type RateLimiter
- type Visitor
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 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 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
Click to show internal directories.
Click to hide internal directories.