Skip to content
/ rate Public

A simple task-granular rate limiter based on the passage of time

License

Notifications You must be signed in to change notification settings

as/rate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rate

Go Report Card

Usage

package main

import (
	"fmt"
	"net/http"
	"time"

	"github.com/as/rate"
	"github.com/as/rate/httprate"
)

func main() {
	lim := rate.New(time.Minute * 5)
	http.Handle("/", httprate.HandlerFunc(lim, time.Minute, nil, func(tx http.ResponseWriter, rx *http.Request) {
		tx.Write([]byte("welcome to /"))
	}))
	fmt.Println(http.ListenAndServe(":80", nil))
}

About

A simple task-granular rate limiter based on the passage of time

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages