Hi guys, I am trying out Aleph with Reitit and Ring and I am running into a problem where my code would just hang up - don't know if this is the correct channel to ask for help, but maybe one of you guys has an idea. I have
(ns app.core
(:require [aleph.http :as http]
[reitit.ring :as ring]
[ring.middleware.params :as params]
[ring.middleware.json :refer [wrap-json-response]]
[ring.util.response :refer [response]]))
(defn return-path-params-handler [req]
(wrap-json-response (response (:path-params req))))
(def handler
(params/wrap-params
(ring/ring-handler
(ring/router
[["/print/:something" return-path-params-handler]])
(ring/create-default-handler))))
(comment
(def http-server (http/start-server #'handler {:port 8080}))
,)
When I do a request to I would expect the response to be
{
"something": "some"
}
But I don't get a response, it just hangs up and also will not timeout. What am I missing here?does it work if you use something trivial for the handler? does (constantly {:status 200 :body "hello world"}) work?
Yes, that works
This also works
(defn return-path-params-handler [req]
(-> (response (:something (:path-params req)))
(assoc :headers {"content-type" "text/plain"})))
Seems to be related to wrap-json-responseDoing this also works
(defn return-path-params-handler [req]
(-> (response (json/write-str {:something "some"}))
(assoc :header {"content-type" "application/json"})))
I will leave it with that for now. Thank you for looking at ithmm i don't know how any of those ring utils work, but i've only seen an aleph server "hang" when the handler returns nil
Problem was that I called wrap-json-response on the response and not the handle itself
That is wrap-json-response returns a handler and not a response
glad it's figured out! 🚀
🙏