feat(auth): lab7 share login limits across replicas and bound Argon2 work
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
|
||||
@@ -30,6 +33,10 @@ func parseUUIDPathParam(c *gin.Context, name string) (string, error) {
|
||||
}
|
||||
|
||||
func respondError(c *gin.Context, err error) {
|
||||
var limit *domain.RateLimitedError
|
||||
if errors.As(err, &limit) {
|
||||
c.Header("Retry-After", strconv.Itoa(limit.Seconds))
|
||||
}
|
||||
reqID := middleware.GetRequestID(c)
|
||||
c.JSON(dto.StatusFromError(err), dto.ErrorFromDomain(err, reqID))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user