Skip to content

didip/tollbooth_chi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tollbooth_chi

Chi middleware for rate limiting HTTP requests.

Five Minutes Tutorial

package main

import (
    "github.com/didip/tollbooth"
    "github.com/didip/tollbooth_chi"
    "github.com/pressly/chi"
    "net/http"
    "time"
)

func main() {
    // Create a limiter struct.
    limiter := tollbooth.NewLimiter(1, nil)

    r := chi.NewRouter()

    r.Use(tollbooth_chi.LimitHandler(limiter))

    r.Get("/", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("Hello, world!"))
    })

    http.ListenAndServe(":12345", r)
}

About

Tollbooth - Chi integration layer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages