Skip to content

Commit

Permalink
change module name
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebulizer1213 committed Jul 21, 2022
1 parent e9e9b7d commit 1366354
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<img src="https://discord.com/api/guilds/844418702430175272/embed.png">
</a>

# GinRateLimit
# gin-rate-limit

GinRateLimit is a rate limiter for the <a href="https://github.com/gin-gonic/gin">gin framework</a>. By default, it can
gin-rate-limit is a rate limiter for the <a href="https://github.com/gin-gonic/gin">gin framework</a>. 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.

Install

```shell
go get github.com/JGLTechnologies/GinRateLimit
go get github.com/JGLTechnologies/gin-rate-limit
```

<br>
Expand All @@ -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"
Expand All @@ -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")
})
Expand All @@ -60,7 +60,7 @@ package main

import (
"github.com/gin-gonic/gin"
"github.com/JGLTechnologies/GinRateLimit"
"github.com/JGLTechnologies/gin-rate-limit"
"time"
)

Expand All @@ -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")
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/JGLTechnologies/GinRateLimit
module github.com/JGLTechnologies/gin-rate-limit

go 1.18

Expand Down
2 changes: 1 addition & 1 deletion GinRateLimit.go → in_memory.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package GinRateLimit
package ratelimit

import (
"github.com/gin-gonic/gin"
Expand Down
2 changes: 1 addition & 1 deletion redis.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package GinRateLimit
package ratelimit

import (
"context"
Expand Down

0 comments on commit 1366354

Please sign in to comment.