1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

Add health endpoint.

This commit is contained in:
Ferdinand Mütsch
2020-04-08 21:29:11 +02:00
parent cd197e855c
commit 7a74ae251c
3 changed files with 38 additions and 4 deletions

View File

@ -18,9 +18,10 @@ import (
)
type AuthenticateMiddleware struct {
UserSrvc *services.UserService
Cache *cache.Cache
Initialized bool
UserSrvc *services.UserService
Cache *cache.Cache
WhitelistPaths []string
Initialized bool
}
func (m *AuthenticateMiddleware) Init() {
@ -35,6 +36,13 @@ func (m *AuthenticateMiddleware) Handle(w http.ResponseWriter, r *http.Request,
m.Init()
}
for _, p := range m.WhitelistPaths {
if strings.HasPrefix(r.URL.Path, p) || r.URL.Path == p {
next(w, r)
return
}
}
var user *models.User
var userKey string
user, userKey, err := m.tryGetUserByPassword(r)