photoprism/internal/server/limiter/abort.go
Michael Mayer 6abbc39017 Security: Add http rate limiter and auto tls mode #98
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-10-11 22:44:11 +02:00

17 lines
444 B
Go

package limiter
import (
"net/http"
"github.com/gin-gonic/gin"
)
// Abort cancels the request with error 429 (too many requests).
func Abort(c *gin.Context) {
c.AbortWithStatus(http.StatusTooManyRequests)
}
// AbortJSON cancels the request with error 429 (too many requests).
func AbortJSON(c *gin.Context) {
c.AbortWithStatusJSON(http.StatusTooManyRequests, gin.H{"error": "rate limit exceeded", "code": http.StatusTooManyRequests})
}