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

set fmt logger for seen userID
This commit is contained in:
2025-10-16 08:29:55 +05:00
parent 8628b5d238
commit 13206a0b39
@@ -6,6 +6,7 @@ import (
"api_bb/pkg/logger" "api_bb/pkg/logger"
"api_bb/pkg/middleware" "api_bb/pkg/middleware"
"api_bb/pkg/utils" "api_bb/pkg/utils"
"fmt"
"net/http" "net/http"
"strconv" "strconv"
@@ -78,6 +79,7 @@ func (h *NewsHandler) GetNewsByID(w http.ResponseWriter, r *http.Request) {
func (h *NewsHandler) CreateNews(w http.ResponseWriter, r *http.Request) { func (h *NewsHandler) CreateNews(w http.ResponseWriter, r *http.Request) {
userID, ok := r.Context().Value(middleware.UserIDKey).(uint) userID, ok := r.Context().Value(middleware.UserIDKey).(uint)
if !ok { if !ok {
fmt.Printf("userid %d", userID)
utils.RespondWithError(w, http.StatusUnauthorized, "Unauthorized") utils.RespondWithError(w, http.StatusUnauthorized, "Unauthorized")
return return
} }