Fork me on GitHub

I'm a beginner at Clojure and have started developing a ring app using Compojure as a learning tool. I've also been looking at Reitit, and get the general impression that dealing with middleware is easier, perhaps much easier, in Reitit. Is my impression correct?

👌 3

I find a variety of examples how to sequentially wrap middleware around the request, using nested function calls, the threading macro, ordering, and the selection of middleware applied to the request, is important for various cases.


This seems confusing to deal with in compojure.


in reitit, the :middleware holds a vector of middleware or data to create middleware. The chain is basically a comp from the chain.


@ikitommi That seems easier to deal with than wrapped functional calls to me, as a beginner. Would you agree?


I definitely like it better.

👍 3

The general advice for a beginner seems to be to start with compojure, but I'm having all sorts of issues getting middleware working with compojure and notice that many others do as well. I'm wondering if reitit users experience the same.


One really cool thing about reitit middleware handling is that if you include [ :as reitit-dev] and then set :reitit.middleware/transform reitit-dev/print-request-diffs in the options to reitit.ring/router, you get an awesome amount of debugging info for tracking down middleware problems.


@manutter51 Thanks for the tip. That sounds very useful.