Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

2manymws/rl

Open more actions menu

Repository files navigation

rl Go Reference build Coverage Code to Test Ratio Test Execution Time

rl is a rate limit middleware for multiple limit rules.

Usage

Prepare an instance that implements rl.Limiter interface.

Then, generate the middleware ( func(next http.Handler) http.Handler ) with rl.New

package main

import (
    "log"
    "net/http"

    "github.com/2manymws/rl"
)

func main() {
    r := http.NewServeMux()
    r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("Hello World"))
    })

    var l rl.Limiter = newMyLimiter()
    m := rl.New(l)

    log.Fatal(http.ListenAndServe(":8080", m(r)))
}

Rate limiting approach

rl uses the Sliding Window Counter pattern same as go-chi/httprate.

Reference

  • go-chi/httprate
    • Most of rl's rate limit implementations refer to httprate. Thanks for the simple and clean implementation!

About

rl is a rate limit middleware for multiple limit rules.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.