Add classification annotations

This commit is contained in:
2025-10-27 23:12:15 +08:00
parent 3990ec01c6
commit 5aacb88c22
44 changed files with 2769 additions and 2241 deletions

View File

@@ -9,6 +9,10 @@ import (
"github.com/gin-gonic/gin"
)
// ============================================================================
// 常量定义
// ============================================================================
const (
CSRFTokenLength = 32
CSRFCookieName = "csrf_token"
@@ -16,6 +20,10 @@ const (
CSRFFormField = "csrf_token"
)
// ============================================================================
// 私有函数
// ============================================================================
// generateRandomBytes 生成指定长度的随机字节
func generateRandomBytes(length int) ([]byte, error) {
bytes := make([]byte, length)
@@ -26,6 +34,10 @@ func generateRandomBytes(length int) ([]byte, error) {
return bytes, nil
}
// ============================================================================
// 公共函数
// ============================================================================
// GenerateCSRFToken 生成CSRF令牌
func GenerateCSRFToken() (string, error) {
bytes, err := generateRandomBytes(CSRFTokenLength)
@@ -190,4 +202,4 @@ func CSRFTokenHandler(c *gin.Context) {
"csrf_token": token,
},
})
}
}