modified: serv_nginx/api_bb/internal/handlers/news_handler.go

log createNews method auth
This commit is contained in:
2025-10-16 10:00:02 +05:00
parent 0c638f72a2
commit 56949ae731
@@ -81,7 +81,12 @@ func (h *NewsHandler) CreateNews(w http.ResponseWriter, r *http.Request) {
userID, ok := r.Context().Value(middleware.UserIDKey).(uint)
logger.Get().Info("userID", zap.Uint("userID", userID))
if !ok {
fmt.Printf("userid %d", userID)
h.logger.Warn("Failed to get userID from context in CreateReview",
zap.String("path", r.URL.Path),
zap.String("method", r.Method),
zap.String("remote_addr", r.RemoteAddr),
zap.Uint("userID", userID),
)
utils.RespondWithError(w, http.StatusUnauthorized, "Unauthorized")
return
}