Compojure ring-json이 json을 반환하지 않음

미가

이 작은 프로그램이 설정되어 있습니다. / hello-world 엔드 포인트가 JSON을 반환 할 것으로 예상하지만 HTTP 본문은 비어 있습니다.

왜 아무것도 반환하지 않는지 아십니까?

(ns easycharge.core
  (:use ring.util.response)
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [easycharge.routes.payments :as payments]
            [easycharge.db.conn :as db]
            [ring.middleware.defaults :refer :all]
            [ring.middleware.json :as middleware]
            [ring.middleware.cors :refer [wrap-cors]]
             )
  (:gen-class))

(defn std-redirect [] (redirect "https://www.hi.com/404/"))

(defroutes app-routes
           (GET "/payments/:env/:id" [env id] {:hi "there"})
           (GET "/hello-world" [] {:msg "hello-world"})
          ;; (payments/get-payment env id)

           ;; serves anything in resources/public
           (route/resources "/")
           (route/not-found (std-redirect)))

(def app (->
           app-routes
           (wrap-cors :access-control-allow-origin [#".*"]
                      :access-control-allow-methods [:get :put :post :delete])
           (middleware/wrap-json-body {:keywords? true :bigdecimals? true})
           (middleware/wrap-json-response)
           (wrap-defaults site-defaults)))
미가

문제는 응답 객체를 (response)fn에 전달하지 않았다는 것 입니다.

예를 들어 hello-world 경로는 다음과 같아야합니다.

(GET "/hello-world" [] (response {:msg "hello-world"}))

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Ring and Compojure-콘텐츠 유형 application / json을 사용한 POST 요청이 작동하지 않습니다.

SPARQLWrapper가 JSON을 반환하지 않음

Midje는 Compojure / Ring 핸들러에서 스터 빙 기능을 제공하지 않습니다.

하위 폴더에 index.html을 제공하는 Ring / Compojure?

Golang Json이 예상 값을 반환하지 않음

FOS Rest Bundle이 적절한 json을 반환하지 않음

Facebook Oembed 응답이 Json을 반환하지 않음

Google WebApp API 호출이 JSON을 반환하지 않음

Java REST API GET이 JSON을 반환하지 않음

Ring 및 Compojure로 데이터 제공

ExceptionHandler가 호출되었지만 JSON을 반환하지 않음

Argrelmin이 값을 반환하지 않음

JSON 요청이 데이터를 반환하지 않음

Node.JS Lambda 함수가 JSON을 반환하지 않음

Angular 4 HTTP가 JSON 본문을 반환하지 않음

Go dialogflow SDK WebhookResponse가 올바른 json을 반환하지 않음

API가 올바른 JSON을 반환하지 않음 (react / express / axios)

Spring Boot Rest Controller API가 json을 반환하지 않음

Laravel에서 JSON 응답을 반환하지 않음

@ResponseBody가 형식을 반환하지 않음 json 오류 406

Laravel 5.4 API가 Postman에서 JSON을 반환하지 않음

서버가 JSON으로 데이터를 반환하지 않음

MVC RedirectToAction이 JSON 포스트 반환 후 작동하지 않음

Spring Boot RestController가 JSON 데이터를 반환하지 않음

Json API가 데이터를 반환하지 않음

JSON이 객체를 반환하지 않음

Thymeleaf 양식이 json 객체를 반환하지 않음

json이있는 jquery $ .post가 결과를 반환하지 않음

값이 0 일 때 WebAPI가 INT에 대한 JSON을 반환하지 않음