Move request limiter to middleware.

This commit is contained in:
2025-07-09 17:00:39 +08:00
parent 0021a73951
commit b568b234c4
11 changed files with 73 additions and 71 deletions

View File

@@ -3,7 +3,6 @@ package service
import (
"errors"
"fmt"
"github.com/gofiber/fiber/v3/log"
"nysoure/server/config"
"nysoure/server/dao"
"nysoure/server/model"
@@ -15,6 +14,8 @@ import (
"time"
"unicode"
"github.com/gofiber/fiber/v3/log"
"golang.org/x/crypto/bcrypt"
)
@@ -376,7 +377,7 @@ func validateUsername(username string) error {
if usernameLen < 3 || usernameLen > 20 {
return model.NewRequestError("Username must be between 3 and 20 characters")
}
for _, r := range []rune(username) {
for _, r := range username {
if r == ' ' || r == '\n' || r == '\r' || r == '\t' || r == '\v' || r == '\f' {
return model.NewRequestError("Username cannot contain whitespace characters")
}