feat: remove pkg

main
git 2024-12-28 21:56:54 +08:00
parent 12c96482d5
commit 94789aaf68
Signed by: git
GPG Key ID: 3F65EFFA44207ADD
1 changed files with 0 additions and 34 deletions

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"log/slog" "log/slog"
"net/http" "net/http"
"path/filepath"
"time" "time"
"github.com/go-chi/chi/v5/middleware" "github.com/go-chi/chi/v5/middleware"
@ -68,36 +67,3 @@ func HandleLogger(next http.Handler) http.Handler {
return http.HandlerFunc(fn) 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)
}