This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-10
Channels
- # aleph (4)
- # aws (2)
- # bangalore-clj (2)
- # beginners (84)
- # boot (25)
- # cider (3)
- # cljsrn (3)
- # clojure (57)
- # clojure-italy (5)
- # clojure-losangeles (3)
- # clojure-russia (7)
- # clojure-spec (18)
- # clojure-uk (29)
- # clojurescript (90)
- # cursive (11)
- # data-science (68)
- # datascript (2)
- # datomic (25)
- # duct (3)
- # fulcro (13)
- # graphql (7)
- # immutant (1)
- # jobs (1)
- # leiningen (12)
- # lumo (1)
- # off-topic (51)
- # om (43)
- # onyx (15)
- # parinfer (10)
- # pedestal (4)
- # re-frame (7)
- # reagent (42)
- # ring-swagger (42)
- # rum (1)
- # shadow-cljs (172)
- # spacemacs (10)
- # specter (4)
- # sql (4)
- # test-check (19)
- # unrepl (54)
- # yada (3)
I’m using a body-params
interceptor to populate the request’s :json-params
. ✓ (I’m a noob)
What if I want to get at the request’s :body
as a String
? I see the :body
isa HttpInputOverHTTP
:
https://www.eclipse.org/jetty/javadoc/current/org/eclipse/jetty/server/HttpInputOverHTTP.html
But I don’t know out to get a String
or a Reader
out of that thing.
Rather than digging directly into the Java stuff, I wondered if there was some interceptor or helper type fn to do that…
(I realize that in general, I may be dealing with a MIME multi-part request and oy I just don’t want that complication, but I do, nevertheless need the content of the first part, as a String
)
I’ve seen the “echo” handler but it punts on the issue: http://pedestal.io/guides/your-first-api
I have a route that looks like this:
["/subscribe" :get [(http-sse/start-event-stream stream-ready)] :route-name :subscribe]
where stream-ready
is defined like this:
(require '[clojure.core.async :as async])
(require '[io.pedestal.http.sse :as sse])
(defn stream-ready
[event-chan ctx]
(async/go-loop []
(async/<! (async/timeout 1000))
(sse/send-event event-chan "example" "test")
(recur)))
In the browser I created an EventSource
object and set the onmessage
handler to just print out the event result. I get a new event message once per second. The event data
looks something like this "[B@100394d9"
, however. That looks a whole lot like how Clojure prints out Byte arrays. I'm wondering if Pedestal is incorrectly serializing SSE messages.
These are the Pedestal dependencies that I have:
[io.pedestal/pedestal.service "0.5.3"]
[io.pedestal/pedestal.route "0.5.3"]
[io.pedestal/pedestal.jetty "0.5.3"]