// GetByUserHandler response posts by user id.
GetByUserHandler response posts by user id.
// GetByUserHandler response posts by user id .
func (pr *PostRouter) GetByUserHandler(w http.ResponseWriter, r *http.Request) {
	userIDStr := chi.URLParam(r, "userId")
	userID, err := strconv.Atoi(userIDStr)
	if err != nil {
		response.HTTPError(w, r, http.StatusBadRequest, err.Error())
		return
	}
	ctx := r.Context()
	posts, err := pr.Repository.GetByUser(ctx, uint(userID))
	if err != nil {
		response.HTTPError(w, r, http.StatusNotFound, err.Error())
		return
	}
	response.JSON(w, r, http.StatusOK, response.Map{"posts": posts})
}
func ( pr * PostRouter ) GetByUserHandler ( w http . ResponseWriter , r * http . Request ) { userIDStr := chi . URLParam ( r , " " ) userID , err := strconv . Atoi ( userIDStr ) if err != nil { response . HTTPError ( w , r , http . StatusBadRequest , err . Error ( ) ) return } ctx := r . Context ( ) posts , err := pr . Repository . GetByUser ( ctx , uint ( userID ) ) if err != nil { response . HTTPError ( w , r , http . StatusNotFound , err . Error ( ) ) return } response . JSON ( w , r , http . StatusOK , response . Map { " " : posts } ) }
GetByUserHandler response posts by user id.
GetByUserHandler response posts by user id .