Fork me on GitHub
#reitit
<
2018-04-29
>
Mic10:04:02

Hi, I'm trying to get the example from the following page to work https://metosin.github.io/reitit/parameter_coercion.html

Mic10:04:56

Actually, the one from here https://github.com/metosin/reitit/blob/master/README.md that has the route /api/math.

Mic10:04:37

When I call it using the provided request

(app {:request-method :get
      :uri "/api/math"
      :query-params {:x "1", :y "2"}})

Mic10:04:52

it works well, but I can't seem to call it using an actual http request from outside the application. I am using immutant, passing the handler like this: (immutant/run (fn [request](app request)) {:port 3000}). The error I get is java.lang.IllegalStateException: Can't coerce body of type class clojure.lang.PersistentArrayMap. I wasn't able to find any examples where the call is made through an actual http client; in the examples the handler is always used by just calling it from the repl.

ikitommi11:04:58

@sokoli.mic reitit doesn’t have all the batteries needed, it’s just a routing lib - so you need some extra middleware to encode & decode params. There are samples under examples, like https://github.com/metosin/reitit/tree/master/examples/ring-swagger.

ikitommi11:04:22

In short, you need wrap-params from ring & wrap-formats from libs like muuntaja.

ikitommi11:04:56

And I think there should be docs “how to run reitit-ring for real”.

Mic12:04:04

@ikitommi Thanks, I'm taking a look 🙂

👍 4
ikitommi12:04:42

@dimovich I’ll take a look

ikitommi14:04:47

@dimovich the public should be resources/public => the create-resource-handler serves from classpath.

ikitommi14:04:17

also, the latest SNAPSHOT supports now :index-files options, defaulting to ["index.html"].

👍 4