Skip to content
Node: express, cors, helmet, morgangithub.com/sahilkhaire/gox/http

RateLimitOptions

Overview

RateLimitOptions configures per-key rate limiting (express-rate-limit).

Part of the http package — Node.js analog: express, cors, helmet, morgan.

RateLimitOptions is a type exported by gox. Methods on this type are documented separately.

Signature

go
type RateLimitOptions struct {
	Requests int
	Window   time.Duration
	Burst    int
	Key      func(*Ctx) string
}

Compare: Node.js · Standard Go · gox

js
// Typical express, cors, helmet, morgan pattern in Node.js
go
func handler(w http.ResponseWriter, r *http.Request) {
    // chi or net/http
}
go
import "github.com/sahilkhaire/gox/http"

opts := http.RateLimitOptions{Max: 100, Window: time.Minute}

Example

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

opts := http.RateLimitOptions{Max: 100, Window: time.Minute}

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