Good morning everyone
I got GET requests working at 2am last night, macroβd out from a small model
Itβs a bit nutty
Morning π It's that time, I'm actually going to understand how Ring works today.
Morning! Raw ring, or adding compojure/reitit on top of it @hugh336?
I'm trying to teach myself reitit and realising an understanding of Ring would be helpful π
You should be good, only weirdness to remember is middleware wraps from the inside out
Oh what do you mean?
So ring middleware is fairly simple, it follows the format:
(defn wrap-something [handler]
(fn [request]
(-> request
do-before
handler
do-after)))
So when you set things up, you do
(-> handler
wrap-first
wrap-second
wrap-third)
So when this endpoint is called, it calls the do-before of wrap-third first, then wrap-second and wrap-first
Then when returning, it does the do-after of wrap-first, then wrap-second, then wrap-third
Itβs not particularly difficult, it just took my head a little to get around when I had to write middleware
Once you understand the pattern, itβs pretty simple to write your own middleware
Right, I think I get the gist of it. I havent used ring before but I know the concept of middlewares with expressjs