modified: serv_nginx/api_bb/internal/handlers/news_handler.go
log createNews method auth
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user