From 94789aaf68c058f8de1e999e3f03163931588137 Mon Sep 17 00:00:00 2001 From: joelei Date: Sat, 28 Dec 2024 21:56:54 +0800 Subject: [PATCH] feat: remove pkg --- http/rest/middleware.go | 34 ---------------------------------- 1 file changed, 34 deletions(-) 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) -}