reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
motform 2020-10-26T08:37:19.181Z

Maybe an obvious question, but how do I redirect SPA routing of all non /api urls for an app that is served using ring-reitit? On Netlify, this is achieved using a _redirects file (`/* /index.html 200`), but for this case I guess I need to create a route?

ikitommi 2020-10-26T17:47:14.184400Z

@love.lagerkvist you should use either a default handler (https://cljdoc.org/d/metosin/reitit/0.5.10/doc/ring/default-handler) or add a catch-all route in the route tree, e.g. ["/*" {:get index-handler}]

ingesol 2020-10-26T19:24:12.186800Z

So I got reitit+malli working nicely for browser routing, coercing path params into proper values. Now I want to coerce the other way, encoding my values into url strings again. (reitit-frontend/match-by-path routes path) does the job for string->parsed-value, what is the best practice in the other direction? Do I use (m/encode …) directly on the path params?

ikitommi 2020-10-30T16:18:50.221600Z

I think there should be in-built support for this. About to need it myself. Also, the frontend schemas should be precompiled in router creation for perf. Can't recall if that is the case today. PRs welcome!

ingesol 2020-10-30T18:17:47.223100Z

That is the case currently, for coercion in

reitit-frontend/match-by-path
But not in
reitit/match-by-name
Maybe I’m misunderstanding something, but coercion in reitit seems to mean string->something. Maybe that’s correct, converting values to strings isn’t coercion, but rather encoding?

ingesol 2020-10-30T18:21:02.223300Z

I do have my schemas precompiled, I just don’t see the reitit api that will use them. And I suspect it doesn’t exist. I will try to see if I can parse the match-by-path code to see how it accesses compiled schemas in the router

hoynk 2020-10-26T19:55:01.188700Z

Not sure this is the place for this question, but I am using reitit with the jetty adapter. I start the server straight from the repl. The question is, is there a debug mode that shows stack traces when the code returns a code 500?

hoynk 2020-10-26T20:04:07.189600Z

Nevermind, the response contains the stack... my bad! Though it has the jetty stack that happens when the handler returns nil.

hoynk 2020-10-26T20:31:26.193700Z

I have another question (I am not sure it is about reitit or jetty) but I created thre tests that basically make a single select in a Cassandra database, the difference between them is that the first was a synchronous ring handler, the second an async one and the third was an async handler using the async mode of the clojure Cassandra lib Alia. The thing is all 3 of them got the same performance (about 2000 req/s in my machine). Can anyone help me understand why there was no difference in performance? Does reitit or jetty automatically handle it somehow?

ingesol 2020-10-26T21:31:13.193800Z

To be clear, I would be running this code:

(reitit-frontend/match-by-name routes :view {:tags #{:x :y :z}})

ingesol 2020-10-26T21:33:03.194Z

Expecting this output path:

"/view/x-y-z"
After my custom coercion that encodes to string by joining with “-”