Fork me on GitHub
#reitit
<
2019-10-25
>
Noah Bogart18:10:01

Hey friends, I'm new to web dev in Clojure (only done some Rails), and I'm slightly confused by what exactly Reitit does. I'm only aware of it because it came in the Reagent template, and I want to make sure I understand. Is there an "intro to routing" tutorial or "intro to Reitit for people who don't know what routing is" tutorial for someone like me?

Noah Bogart18:10:21

lol Maybe I shouldn't start with Reitit, but reading about Ring made slightly more sense and this caught me off guard

manutter5118:10:44

Reitit is fairly new, before that a lot of people used Compojure. Basically, the idea is that reitit is a router, i.e. the bit that makes the connection between /user/login, and the code that should handle requests sent to the /user/login URI. There’s some other stuff reitit does too, like letting you embed parameters in the URI, so that if a user goes to /product/1234/details, you can define the route as product/:product-id/details, and your request handler will get a path parameter of {:product-id 1234}.

manutter5118:10:36

The big difference between reitit and compojure is how it handles middleware (code that processes the request before it gets to your request-handler, and post-processes the response after it is returned by your request handler). Compojure tends to run all requests through a common middleware stack, but reitit lets you define different sets of middleware for different routes or sets of routes.

manutter5118:10:37

If you’re just starting out, though, and you want to read up on the basics, you might want to look into ring and compojure, and then you’ll have a good basis for understanding what reitit is doing, and why.

👍 12
Noah Bogart18:10:51

Cool, I'll check out compojure!

Noah Bogart18:10:54

thanks so much for the detailed answer, i appreciate it