reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
kommen 2021-06-24T12:21:57.097300Z

went ahead and filed a PR including a test, feedback very welcome https://github.com/metosin/reitit/pull/495

jaley 2021-06-24T13:55:43.102900Z

Hey everyone! Does anyone know of any docs/examples I can read on recommended ways to split client and server side routing with reitit? A little more context. I'm starting a project with the default reagent template. It's set up by default to use reitit both server and client side. The server-side implementation essentially has all the client routes duplicated, simply returning a 200 and rendering the main landing page, so that the client code can then check the URL and navigate accordingly. That works, I'm just trying to avoid duplicating all my client-side routes in the server-side ring router if I can, and figure there must be a way people usually do this. These are the things I already considered, just wondering if anyone has a better way: • structure routes such that client and api routes have common prefixes respectively, then have a catch-all handler in the server to send all client routes a 200 and let the frontend handle it • move the router data structure to cljc, seeing as it's just data

athomasoriginal 2021-06-24T15:05:32.103100Z

Is this a spa?

athomasoriginal 2021-06-24T15:08:13.103300Z

If yes, generally speaking a pattern is to have a single catch-all route on the backend and then one writes their routes for the SPA on the front end so you end up writing it once

jaley 2021-06-24T18:57:20.103600Z

Yeah, it's an SPA. OK, thanks, I think that's pretty much what I had in mind with my first suggestion. I have a bunch of /api backend routes, and if the request doesn't match them, I let the front end handle it. Presumably this would mean that invalid requests technically receive a 200 status code, but the page rendered would be displaying an error?

athomasoriginal 2021-06-24T19:03:59.103800Z

> invalid requests technically receive a 200 status code, but the page rendered would be displaying an error? Yep, that’s def one way to handle it 🙂