Skip to content

Commit

Permalink
fix: errors in middleware do not abort the request
Browse files Browse the repository at this point in the history
  • Loading branch information
stonith404 committed Nov 1, 2024
1 parent 5b9f4d7 commit 376d747
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/internal/middleware/file_size_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func (m *FileSizeLimitMiddleware) Add(maxSize int64) gin.HandlerFunc {
if err := c.Request.ParseMultipartForm(maxSize); err != nil {
err = &common.FileTooLargeError{MaxSize: formatFileSize(maxSize)}
c.Error(err)
c.Abort()
return
}
c.Next()
Expand Down
1 change: 1 addition & 0 deletions backend/internal/middleware/jwt_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func (m *JwtAuthMiddleware) Add(adminOnly bool) gin.HandlerFunc {
return
} else {
c.Error(&common.NotSignedInError{})
c.Abort()
return
}
}
Expand Down
1 change: 1 addition & 0 deletions backend/internal/middleware/rate_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (m *RateLimitMiddleware) Add(limit rate.Limit, burst int) gin.HandlerFunc {
limiter := getLimiter(ip, limit, burst)
if !limiter.Allow() {
c.Error(&common.TooManyRequestsError{})
c.Abort()
return
}

Expand Down

0 comments on commit 376d747

Please sign in to comment.