Closed blazeroot closed 9 years ago
Hello! I can't get transit-json and transit-msgpack response format to work. I'm using http-kit and sending test request with curl.
http-kit
curl
Let me show test:
(ns siliconboard.core (:use org.httpkit.server) (:require [ring.middleware.reload :as reload] [ring.middleware.logger :as logger] [ring.middleware.format-response :refer [wrap-restful-response]] [ring.middleware.format-params :refer [wrap-restful-params]] [onelog.core :as onelog] [siliconboard.app :as app])) (defonce server (atom nil)) (defn stop-server [] (when-not (nil? @server) (@server :timeout 100) (reset! server nil))) (defn in-dev? [& args] true) ;; TODO (defn -main [& args] (let [handler (if (in-dev? args) (reload/wrap-reload #'app/app) #'app/app)] (onelog/start! "/dev/stdout") (reset! server (run-server (-> handler (wrap-restful-params) (wrap-restful-response) (logger/wrap-with-logger)) {:port 3000}))))
(ns siliconboard.app (:require [compojure.core :refer [defroutes GET]] [ring.util.response :refer [response]])) (defroutes app (GET "/" [] "index") (GET "/example" [] (response {:name "name" :email "a@a.net" :password "password"})))
When I'm trying to get transit formatted response:
> curl --header "Accept: application/transit+json" -D - localhost:3000/example HTTP/1.1 500 Internal Server Error Content-Length: 79 Server: http-kit Date: Sat, 08 Nov 2014 21:25:47 GMT count not supported on this type: format_response$wrap_format_response$fn__1297%
That's exactly that line: https://github.com/ngrunwald/ring-middleware-format/blob/e6917b18aff648047c7c731e579371512b8c0f43/src/ring/middleware/format_response.clj#L189
I stuck, idk If I'm doing something wrong or it's bug in middleware?
btw. other formats work well
> curl --header "Accept: application/json" -D - localhost:3000/example HTTP/1.1 200 OK Content-Length: 52 Content-Type: application/json; charset=utf-8 Content-Length: 52 Server: http-kit Date: Sat, 08 Nov 2014 21:34:25 GMT {"email":"me@a.com","password":"pass","name":"name"}%
There is a PR #26 that fixes wrap-restful-response for transit.
@minimal Ohhhh. I didn't notice it. Thanks! Closing that one.
Hello! I can't get transit-json and transit-msgpack response format to work. I'm using
http-kit
and sending test request withcurl
.Let me show test:
When I'm trying to get transit formatted response:
That's exactly that line: https://github.com/ngrunwald/ring-middleware-format/blob/e6917b18aff648047c7c731e579371512b8c0f43/src/ring/middleware/format_response.clj#L189
I stuck, idk If I'm doing something wrong or it's bug in middleware?
btw. other formats work well