修改middleware包

This commit is contained in:
2025-11-05 18:38:41 +08:00
parent ef4ca397ce
commit 3e2f9e7210
4 changed files with 27 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
package api
import (
"context"
"net/http"
"net/http/pprof"
@@ -52,8 +53,8 @@ func (a *API) setupRoutes() {
// --- Authenticated Routes ---
// 所有在此注册的路由都需要通过 JWT 身份验证
authGroup := a.echo.Group("/api/v1")
authGroup.Use(middleware.AuthMiddleware(a.tokenService, a.userRepo)) // 1. 身份认证中间件
authGroup.Use(middleware.AuditLogMiddleware(a.auditService)) // 2. 审计日志中间件
authGroup.Use(middleware.AuthMiddleware(logs.AddCompName(context.Background(), "AuthMiddleware"), a.tokenService, a.userRepo)) // 1. 身份认证中间件
authGroup.Use(middleware.AuditLogMiddleware(logs.AddCompName(context.Background(), "AuditLogMiddleware"), a.auditService)) // 2. 审计日志中间件
{
// 用户相关路由组
userGroup := authGroup.Group("/users")