A useful gas that used to limit every request for the web applications built using Air.
Open your terminal and execute
$ go get github.com/air-gases/limiter
done.
The only requirement is the Go, at least v1.13.
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()
}
If you want to discuss Limiter, or ask questions about it, simply post questions or ideas here.
If you want to help build Limiter, simply follow this to send pull requests here.
This project is licensed under the MIT License.
License can be found here.