Skip to content

Commit

Permalink
Simplifying CORS implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitbbhayani committed Dec 16, 2024
1 parent 3540215 commit 20a0206
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 50 deletions.
41 changes: 0 additions & 41 deletions internal/middleware/cors.go

This file was deleted.

8 changes: 0 additions & 8 deletions internal/middleware/ratelimiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ func NewRateLimiterMiddleware(client *db.DiceDB, limit int64, window float64) (r

// RateLimiter middleware to limit requests based on a specified limit and duration
func (rl *RateLimiterMiddleware) Exec(c *gin.Context) {
if handleCors(c.Writer, c.Request) {
return
}

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

Expand Down Expand Up @@ -133,10 +129,6 @@ func calculateNextCleanupTime(ctx context.Context, client *db.DiceDB, cronFreque

func MockRateLimiter(client *mock.DiceDBMock, next http.Handler, limit int64, window float64) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if handleCors(w, r) {
return
}

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func main() {
}
c.Next()
})

router.Use(middleware.TrailingSlashMiddleware)
router.Use((middleware.NewRateLimiterMiddleware(diceDBAdminClient,
configValue.Server.RequestLimitPerMin,
Expand Down

0 comments on commit 20a0206

Please sign in to comment.