Fork me on GitHub
#ring-swagger
<
2017-01-27
>
ikitommi07:01:26

I think that could be useful, at least for new users.

mrchance15:01:13

Hi, how can I access the original ring request in compojure api handlers? I saw a let to +original_request_or_something+ in the code, should I use that or do it differently? Use case: I have a bunch of query parameters that I want documented in my swagger, but that I would just like to access as the query-param map

mrchance15:01:13

(would also be nice for the http-kit channel and so on)

bja15:01:25

you can just bind request ala (GET "/foo" request :query-params [bar :- s/Int] (ok (get-in request [:query-params :bar]))

mrchance15:01:07

ah, so that's what the [] is for! Thanks 😉

bja15:01:47

the [] is a destructuring call that captures nothing. You could also use map-based destructuring {:keys [query-params]} or just give the whole ring request a name like request

mrchance15:01:10

perfect, thanks

mrchance15:01:14

Works like a charm ^^