Fix: notify bot

This commit is contained in:
Grail Finder
2025-05-22 16:47:49 +03:00
parent 31f721cd43
commit c155654d5f
7 changed files with 84 additions and 90 deletions

View File

@ -5,24 +5,22 @@ import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"errors"
"golias/models"
"net/http"
"time"
)
// LogRequests logs all HTTP requests with method, path and duration
func LogRequests(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
// start := time.Now()
// Wrap response writer to capture status code
next.ServeHTTP(w, r)
duration := time.Since(start)
log.Debug("request completed",
"method", r.Method,
"path", r.URL.RequestURI(),
"duration", duration.String(),
)
// duration := time.Since(start)
// log.Debug("request completed",
// "method", r.Method,
// "path", r.URL.RequestURI(),
// "duration", duration.String(),
// )
})
}
@ -65,11 +63,11 @@ func GetSession(next http.Handler) http.Handler {
return
}
userSession, err := cacheGetSession(sessionToken)
log.Debug("userSession from cache", "us", userSession)
// log.Debug("userSession from cache", "us", userSession)
if err != nil {
msg := "auth failed; session does not exists"
err = errors.New(msg)
log.Debug(msg, "error", err)
// msg := "auth failed; session does not exists"
// err = errors.New(msg)
// log.Debug(msg, "error", err)
next.ServeHTTP(w, r)
return
}