diff --git a/http/rest/middleware.go b/http/rest/middleware.go index 8e348ac..163db50 100644 --- a/http/rest/middleware.go +++ b/http/rest/middleware.go @@ -6,7 +6,6 @@ import ( "fmt" "log/slog" "net/http" - "path/filepath" "time" "github.com/go-chi/chi/v5/middleware" @@ -68,36 +67,3 @@ func HandleLogger(next http.Handler) http.Handler { return http.HandlerFunc(fn) } - -// AuthRequired API类型, 兼容多种鉴权模式 -func AuthRequired(next http.Handler) http.Handler { - ignoreExtMap := map[string]struct{}{ - ".js": {}, - ".css": {}, - ".map": {}, - ".png": {}, - } - - fn := func(w http.ResponseWriter, r *http.Request) { - if r.Method == http.MethodOptions { - next.ServeHTTP(w, r) - return - } - - // 静态资源过滤, 注意不会带鉴权信息 - fileExt := filepath.Ext(r.URL.Path) - if _, ok := ignoreExtMap[fileExt]; ok { - next.ServeHTTP(w, r) - return - } - - // switch { - // default: - // render.Render(w, r, rest.AbortWithUnauthorizedError(rest.UnauthorizedError)) - // return - // } - - next.ServeHTTP(w, r) - } - return http.HandlerFunc(fn) -}