Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akdilsiz/limiterphi
phi middleware of ulule/limiter package
https://github.com/akdilsiz/limiterphi
api golang rate-limiter
Last synced: about 1 month ago
JSON representation
phi middleware of ulule/limiter package
- Host: GitHub
- URL: https://github.com/akdilsiz/limiterphi
- Owner: akdilsiz
- License: mit
- Created: 2020-01-07T22:15:39.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-05-20T10:56:07.000Z (over 2 years ago)
- Last Synced: 2023-08-12T07:39:52.720Z (over 1 year ago)
- Topics: api, golang, rate-limiter
- Language: Go
- Size: 29.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Limiter Phi
[![CircleCI](https://circleci.com/gh/akdilsiz/limiterphi/tree/master.svg?style=svg)](https://circleci.com/gh/akdilsiz/limiterphi/tree/master)
[![GitHub license](https://img.shields.io/github/license/akdilsiz/limiterphi)](https://github.com/akdilsiz/limiterphi/blob/master/LICENSE)
[![codecov](https://codecov.io/gh/akdilsiz/limiterphi/branch/master/graph/badge.svg)](https://codecov.io/gh/akdilsiz/limiterphi)
[![Go Report Card](https://goreportcard.com/badge/github.com/akdilsiz/limiterphi)](https://goreportcard.com/report/github.com/akdilsiz/limiterphi)\
phi middleware of **[ulule/limiter](https://github.com/ulule/limiter)** package.\
For detailed documentation [https://github.com/ulule/limiter](https://github.com/ulule/limiter)## Example
```go
package mainimport (
"github.com/akdilsiz/limiterphi"
"github.com/fate-lovely/phi"
"github.com/ulule/limiter/v3"
"github.com/ulule/limiter/v3/drivers/store/memory"
"github.com/valyala/fasthttp"
"log"
)func main() {
store := memory.NewStore()rate, err := limiter.NewRateFromFormatted("10-M")
if err != nil {
panic(err)
}
middleware := limiterphi.NewMiddleware(limiter.New(store, rate))router := phi.NewRouter()
router.Use(middleware.Handle)
router.Get("/", func(ctx *fasthttp.RequestCtx) {
ctx.SetStatusCode(fasthttp.StatusOK)
ctx.SetContentType("application/json")
ctx.SetBodyString(`{"message":"OK"}`)
})log.Fatal(fasthttp.ListenAndServe(":3001", router.ServeFastHTTP))
}
```## LICENSE
[MIT](https://github.com/akdilsiz/limiterphi/LICENSE)