Skip to content
phi middleware of ulule/limiter package
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
README.md
go.mod
go.sum
limiterphi.go
limiterphi_test.go
options.go

README.md

Limiter Phi

Build Status GitHub license codecov Go Report Card
phi middleware of ulule/limiter package.
For detailed documentation https://github.com/ulule/limiter

Example

package main

import (
    "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

You can’t perform that action at this time.