Skip to content
This repository was archived by the owner on Oct 17, 2023. It is now read-only.

Latest commit

 

History

History
63 lines (44 loc) · 1.34 KB

README.md

File metadata and controls

63 lines (44 loc) · 1.34 KB

Limiter

PkgGoDev

A useful gas that used to limit every request for the web applications built using Air.

Installation

Open your terminal and execute

$ go get github.com/air-gases/limiter

done.

The only requirement is the Go, at least v1.13.

Usage

The following application will limit the body size of all requests to within 1 MB.

package main

import (
	"github.com/air-gases/limiter"
	"github.com/aofei/air"
)

func main() {
	a := air.Default
	a.DebugMode = true
	a.Pregases = []air.Gas{
		limiter.BodySizeGas(limiter.BodySizeGasConfig{
			MaxBytes: 1 << 20,
		}),
	}
	a.GET("/", func(req *air.Request, res *air.Response) error {
		return res.WriteString("You are within the limits.")
	})
	a.Serve()
}

Community

If you want to discuss Limiter, or ask questions about it, simply post questions or ideas here.

Contributing

If you want to help build Limiter, simply follow this to send pull requests here.

License

This project is licensed under the MIT License.

License can be found here.