chore: initial import 萌邮 MengPost (React+Vite + Go+Gin)

Made-with: Cursor
This commit is contained in:
2026-04-17 22:27:57 +08:00
commit 0c31a4b376
40 changed files with 4263 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package handlers
import (
"net/http"
"github.com/gin-gonic/gin"
"mengpost-backend/config"
)
// VerifyToken 供前端 token 弹窗使用: 仅返回 token 是否正确.
func VerifyToken(cfg *config.Config) gin.HandlerFunc {
return func(c *gin.Context) {
var body struct {
Token string `json:"token"`
}
if err := c.ShouldBindJSON(&body); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid body"})
return
}
if body.Token != cfg.Token {
c.JSON(http.StatusUnauthorized, gin.H{"ok": false})
return
}
c.JSON(http.StatusOK, gin.H{"ok": true})
}
}