From 1366354506936295bea67e885808cad6a7833386 Mon Sep 17 00:00:00 2001 From: Nebulizer1213 Date: Thu, 21 Jul 2022 09:21:20 -0400 Subject: [PATCH] change module name --- README.md | 18 +++++++++--------- go.mod | 2 +- GinRateLimit.go => in_memory.go | 2 +- redis.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) rename GinRateLimit.go => in_memory.go (98%) diff --git a/README.md b/README.md index 9ecda7c..f0bcfc1 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ -# GinRateLimit +# gin-rate-limit -GinRateLimit is a rate limiter for the gin framework. By default, it can +gin-rate-limit is a rate limiter for the gin framework. By default, it can only store rate limit info in memory and with redis. If you want to store it somewhere else you can make your own store or use third party stores. The library is new so there are no third party stores yet, so I would appreciate if someone could make one. @@ -12,7 +12,7 @@ could make one. Install ```shell - go get github.com/JGLTechnologies/GinRateLimit + go get github.com/JGLTechnologies/gin-rate-limit ```
@@ -23,7 +23,7 @@ Redis Example package main import ( - "github.com/JGLTechnologies/GinRateLimit" + "github.com/JGLTechnologies/gin-rate-limit" "github.com/gin-gonic/gin" "github.com/go-redis/redis/v8" "time" @@ -40,10 +40,10 @@ func errorHandler(c *gin.Context, remaining time.Duration) { func main() { server := gin.Default() // This makes it so each ip can only make 5 requests per second - store := GinRateLimit.RedisStore(time.Second, 5, redis.NewClient(&redis.Options{ + store := ratelimit.RedisStore(time.Second, 5, redis.NewClient(&redis.Options{ Addr: "localhost:7680", }), false) - mw := GinRateLimit.RateLimiter(keyFunc, errorHandler, store) + mw := ratelimit.RateLimiter(keyFunc, errorHandler, store) server.GET("/", mw, func(c *gin.Context) { c.String(200, "Hello World") }) @@ -60,7 +60,7 @@ package main import ( "github.com/gin-gonic/gin" - "github.com/JGLTechnologies/GinRateLimit" + "github.com/JGLTechnologies/gin-rate-limit" "time" ) @@ -75,8 +75,8 @@ func errorHandler(c *gin.Context, remaining time.Duration) { func main() { server := gin.Default() // This makes it so each ip can only make 5 requests per second - store := GinRateLimit.InMemoryStore(time.Second, 5) - mw := GinRateLimit.RateLimiter(keyFunc, errorHandler, store) + store := ratelimit.InMemoryStore(time.Second, 5) + mw := ratelimit.RateLimiter(keyFunc, errorHandler, store) server.GET("/", mw, func(c *gin.Context) { c.String(200, "Hello World") }) diff --git a/go.mod b/go.mod index 9820d91..bb31750 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/JGLTechnologies/GinRateLimit +module github.com/JGLTechnologies/gin-rate-limit go 1.18 diff --git a/GinRateLimit.go b/in_memory.go similarity index 98% rename from GinRateLimit.go rename to in_memory.go index 0777d92..baa3dec 100644 --- a/GinRateLimit.go +++ b/in_memory.go @@ -1,4 +1,4 @@ -package GinRateLimit +package ratelimit import ( "github.com/gin-gonic/gin" diff --git a/redis.go b/redis.go index 3b5b107..fa93ade 100644 --- a/redis.go +++ b/redis.go @@ -1,4 +1,4 @@ -package GinRateLimit +package ratelimit import ( "context"