Re: ring-transit issue

2014-12-02 Thread Thomas
Hi,

After quite a bit of trying various things I got this working now:

(ns trans.core.handler
  (:require [compojure.core :refer :all]
[compojure.route :as route]
[compojure.handler :as handler]
[ring.util.response :as ring-response]
[ring.middleware.transit :as trans :only [wrap-transit-response 
wrap-transit-params]]))

(defn get-data []
  (ring-response/response {:a 1 :b 2}))

(defroutes app-routes
  (GET "/" [] "Hello World")
  (GET "/test" [] (get-data))
  (route/not-found "Not Found"))

(def app
  (-> app-routes
  (handler/site)
  (trans/wrap-transit-params)
  (trans/wrap-transit-response)))

The change that made the difference seems to the the ring-response/response 
call in the get-data function.

I hope that this helps other people and a big thank you to Ahmad for a hint 
in the right direction.

Thomas

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ring-transit issue

2014-11-28 Thread Ahmad Hammad
Remove wrap-transit-response from your routes. You need to add 
(wrap-transit-response) to your middleware just like you have 
(wrap-transit-params). The latter handles incoming request params, while 
the former response collections.

On Friday, November 28, 2014 2:00:20 PM UTC, Thomas wrote:
>
> Hi,
>
> I am using the ring-transit middleware but something doesn't seem to be 
> quite right. Below is the code on the server side:
>
> (defn get-test-data []
>   {:a 1 :b 2})
>
> (defroutes app-routes
>   (GET "/" [] (main-page))
>   (wrap-transit-response
> (GET "/test" [] (get-test-data)))
>   (route/resources "/")
>   (route/not-found "Not Found"))
>
> (def app
>   (-> app-routes
>   (handler/site)
>   (wrap-transit-params)))
>
> On the client I am getting this error when using cljs-ajax:
>
> something bad happened: 200 Unexpected end of input  Format should have 
> been Transit
>
> and the content-length is reported as 0 by postman. I am sure the error is 
> between my ears ;)  but I have no idea what!! Any ideas?
>
> TIA,
> Thomas
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ring-transit issue

2014-11-28 Thread Thomas
Hi,

I am using the ring-transit middleware but something doesn't seem to be 
quite right. Below is the code on the server side:

(defn get-test-data []
  {:a 1 :b 2})

(defroutes app-routes
  (GET "/" [] (main-page))
  (wrap-transit-response
(GET "/test" [] (get-test-data)))
  (route/resources "/")
  (route/not-found "Not Found"))

(def app
  (-> app-routes
  (handler/site)
  (wrap-transit-params)))

On the client I am getting this error when using cljs-ajax:

something bad happened: 200 Unexpected end of input  Format should have 
been Transit

and the content-length is reported as 0 by postman. I am sure the error is 
between my ears ;)  but I have no idea what!! Any ideas?

TIA,
Thomas

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.