modified: serv_nginx/api_bb/internal/handlers/news_handler.go
set fmt logger for seen userID
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user