feat: remove pkg
parent
12c96482d5
commit
94789aaf68
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue