This commit is contained in:
oneao committed 2026-02-27 17:29:28 +08:00
1 parent 1903861354
commit 1b1a54f7dd
35 files changed
+1185 -535

No files matched your search

@@ -13,7 +13,6 @@ const CtxUserIDKey = "user_id"
// Auth 登录校验中间件
func Auth() fiber.Handler {
return func(c fiber.Ctx) error {
token := strings.TrimSpace(c.Get("Token"))
if token == "" {
return responsex.Unauthorized(c, "未登录")
+5 -2
View File
@@ -2,6 +2,8 @@ package router
import (
"allapp/api/handler/auth"
"allapp/api/handler/space"
"allapp/api/router/middleware"
"allapp/config"
"github.com/gofiber/fiber/v3"
@@ -14,7 +16,7 @@ func SetupRouters(app *fiber.App) {
publicGroup := api.Group("")
// 2️⃣ 需要登录
//authGroup := api.Group("", middleware.Auth())
authGroup := api.Group("", middleware.Auth())
//
//// 3️⃣ 需要登录 + 需要空间
//spaceGroup := api.Group("", middleware.Auth(), middleware.SpaceGuard())
@@ -25,7 +27,8 @@ func SetupRouters(app *fiber.App) {
authRouter.Post("/login/qq", auth.LoginQq)
authRouter.Post("/login/wechat", auth.LoginWechat)
// 示例
// 空间操作
authGroup.Post("/space/create", space.CreateSpace)
// authGroup.Get("/user/profile", user.GetProfile)
// spaceGroup.Get("/space/info", space.GetInfo)
}