reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
subsaharancoder 2020-09-30T01:06:03.029800Z

What do I need to add to my reitit handler or controller in order to display json? I keep getting this error:

java.lang.IllegalArgumentException: No implementation of method: :write-body-to-stream of protocol: #'ring.core.protocols/StreamableResponseBody found for class: clojure.lang.PersistentArrayMap

subsaharancoder 2020-09-30T01:09:04.029900Z

adding wrap-json-body and wrap-json-response as middleware fixed this

Tzafrir Ben Ami 2020-09-30T03:29:50.030100Z

Consider using https://github.com/metosin/muuntaja

2020-09-30T05:12:33.030400Z

It looks like there is a bug in the latest ring-swagger-ui. I can use this route

["/auth" {:post       (constantly (ok {:okey "dokey"}))
           :parameters {:form {:username string?}}
           :responses  {200 {:body {:okey string?}}}}]
and I always get the above connection close result. If I revert to metosin/ring-swagger-ui version 2.2.10 the endpoint works. I'd be happy to post a more complete example if needed. Also, here's the output from the developer console if that's helpful:

joshkh 2020-09-30T09:03:53.036300Z

does/should coercion work on application/x-www-form-urlencoded parameters? i normally see parameters like :path and :body merged into the request's :parameters map, but i'm not seeing any form data there. perhaps i'm using the wrong parameters key :form-params but i can't find in the documentation a list of valid ones; only examples of :multipart :body :path :query

["/catalogue" {:post {:parameters {:form-params {:testparam uuid?}}
                      :handler    (fn [req]
                                    ; has uncoerced string values in a `:form-params` key:
                                    (clojure.pprint/pprint e)
                                    ; empty map:
                                    (r/ok {:parameters (:parameters req)}))}}]

joshkh 2020-09-30T09:10:02.036900Z

of course i finally found it after posting my question 🙂 the key should be :form https://github.com/metosin/reitit/blob/master/doc/coercion/coercion.md#defining-parameters

thomas 2020-09-30T12:20:31.038900Z

Hi, I am trying to use Reitit in the browser and I have this route: ["/new-incident" {:name ::new-incident :view new-incident}]

thomas 2020-09-30T12:22:13.039700Z

and this in my [:a {:href (rfe/href ::new-incident)} ..

thomas 2020-09-30T12:22:51.040500Z

but for some reason it doesn't know what to do... the second line is in a different name-space, not sure if that matters though.

thomas 2020-09-30T13:01:51.041300Z

now I get the following warning:

thomas 2020-09-30T13:02:02.041500Z

ns: "app.components.button", name: "new-incident", fqn: "app.components.button/new-incident"

juhoteperi 2020-09-30T13:06:28.042600Z

@thomas Yes, that matters if you are using namespaced keywords. Use :route.ns.here/new-incident on the href call.

thomas 2020-09-30T13:07:04.043100Z

thank you, let me give that a try.

thomas 2020-09-30T13:08:45.043600Z

cool, the URL updates... now the page 😉

thomas 2020-09-30T13:33:15.044600Z

so for some reason my page doesn't change, even though I have a new-incident function. :thinking_face: