fix review

This commit is contained in:
icefed
2023-02-06 20:30:20 +08:00
committed by nkanaev
parent 66f2a973a3
commit 7cf27e0fde
5 changed files with 103 additions and 73 deletions

View File

@@ -9,10 +9,10 @@ import (
)
type Middleware struct {
Username string
Password string
BasePath string
SkipAuthPaths []string
Username string
Password string
BasePath string
Public []string
}
func unsafeMethod(method string) bool {
@@ -20,7 +20,7 @@ func unsafeMethod(method string) bool {
}
func (m *Middleware) Handler(c *router.Context) {
for _, path := range m.SkipAuthPaths {
for _, path := range m.Public {
if strings.HasPrefix(c.Req.URL.Path, m.BasePath+path) {
c.Next()
return