Skip to content
Node: express-rate-limitgithub.com/sahilkhaire/gox/http

Middleware.RateLimit

Overview

RateLimit returns middleware that limits requests per key.

If you are coming from Node.js, the closest pattern is express-rate-limit.

Method on Middleware — call it on a value of that type after constructing or receiving one from a constructor.

Signature

go
func RateLimit(opts RateLimitOptions) Middleware

Compare: Node.js · Standard Go · gox

js
express-rate-limit
go
func handler(w http.ResponseWriter, r *http.Request) {
    // chi or net/http
}
go
import "github.com/sahilkhaire/gox/http"

http.RateLimit

Example

go
import "github.com/sahilkhaire/gox/http"

http.RateLimit

Tips

Stack Logger, Recover, and Security middleware the way you would morgan + helmet in Express.

Standard library alternative

Use the standard library directly:

go
func handler(w http.ResponseWriter, r *http.Request) {
    // chi or net/http
}

Back to http package overview

MIT Licensed · Built for Node.js developers moving to Go