// GetOneHandler response one post by id.
GetOneHandler response one post by id.
// GetOneHandler response one post by id .
func (pr *PostRouter) GetOneHandler(w http.ResponseWriter, r *http.Request) {
	idStr := chi.URLParam(r, "id")
	id, err := strconv.Atoi(idStr)
	if err != nil {
		response.HTTPError(w, r, http.StatusBadRequest, err.Error())
		return
	}
	ctx := r.Context()
	p, err := pr.Repository.GetOne(ctx, uint(id))
	if err != nil {
		response.HTTPError(w, r, http.StatusNotFound, err.Error())
		return
	}
	response.JSON(w, r, http.StatusOK, response.Map{"post": p})
}
func ( pr * PostRouter ) GetOneHandler ( w http . ResponseWriter , r * http . Request ) { idStr := chi . URLParam ( r , " " ) id , err := strconv . Atoi ( idStr ) if err != nil { response . HTTPError ( w , r , http . StatusBadRequest , err . Error ( ) ) return } ctx := r . Context ( ) p , err := pr . Repository . GetOne ( ctx , uint ( id ) ) if err != nil { response . HTTPError ( w , r , http . StatusNotFound , err . Error ( ) ) return } response . JSON ( w , r , http . StatusOK , response . Map { " " : p } ) }
GetOneHandler response one post by id.
GetOneHandler response one post by id .