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?
@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}]
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?
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!
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?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
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?
Nevermind, the response contains the stack... my bad! Though it has the jetty stack that happens when the handler returns nil.
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?
To be clear, I would be running this code:
(reitit-frontend/match-by-name routes :view {:tags #{:x :y :z}})
Expecting this output path:
"/view/x-y-z"
After my custom coercion that encodes to string by joining with “-”