This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-25
Channels
- # aws (2)
- # beginners (57)
- # boot (31)
- # carry (15)
- # cider (9)
- # cljs-dev (9)
- # cljs-experience (32)
- # cljsrn (94)
- # clojure (129)
- # clojure-dusseldorf (3)
- # clojure-greece (4)
- # clojure-italy (8)
- # clojure-norway (3)
- # clojure-russia (344)
- # clojure-sg (39)
- # clojure-spec (2)
- # clojure-uk (39)
- # clojurescript (84)
- # core-async (99)
- # cursive (10)
- # data-science (1)
- # datascript (4)
- # datomic (66)
- # emacs (10)
- # graphql (4)
- # hoplon (28)
- # jobs (15)
- # luminus (3)
- # lumo (5)
- # off-topic (23)
- # om (4)
- # onyx (32)
- # pedestal (24)
- # re-frame (2)
- # reagent (7)
- # ring-swagger (32)
- # spacemacs (4)
- # untangled (57)
- # utah-clojurians (1)
I have a core.async chan of database rows I’d like to return as my response body, but the content type should be transit+json and I’m not sure if it’s possible to encode the channel properly?
@jfntn Hmm… I think there are a couple of parts there. You should be able to set the Content-Type header directly in your response map.
There’s also an interceptor that should emit the correct encoding… one sec while I look it up.
What is the data type that the channel messages will be? You may need a transducer on the channel to turn a JDBC object into a map for the transit-json-body
So the chan will contain one map per row (from cassandra through the alia library). I should have added that I was hoping I could stream the response and have it end up on the client as a vector/collection
Ah, I see. But the whole collection of rows will never be a single data structure in memory, right?
My first attempt was to transduce the chan with transit/write
but the client ends up reading the first map only
I can’t think of a really clean way to do it. You might be able to cheat a bit though.
If your transducer emits a \[ before the first row, and a \] after the last row, then the client will think it’s got a single collection.
I could accumulate the results in memory and return a data strucute just to get it to work now, but it’d be great to know whether this could be solved in the future since our responses will get bigger over time
@souenzzo you can map the extra information to route-name-extra map. Then you can get those extra information in any interceptor:
(def route-name-extra-map
{:route-name-a [...]})
Is there a way to mount a route table into another one? so, if I have a defroutes
in one namespace, and I want to mount all those routes at a particular path in the master service/routes
table, how would I do that?
@cap10morgan You’ll have to defer expanding the routes, so just use def
instead of defroutes
. At that point, the route table is just data so you could update the path portion with a map and string concatenation
@mtnygard OK, thanks. Will play around with that.
@mtnygard When I tried this, I found that the repeated "/" at the root of my nested routes caused a double //
to be required in the URL for the route to match more deeply-nested routes in the table (using the linear-search router). It did match that nested-root route, though. Does that seem like a bug?
And I'll add, print-routes
only shows one /
separating those path components, so at least that part of the system seems to consolidate them.
this is with 0.5.2