Search code examples
clojurecompojurering

How to redirect users to a different page if they aren't logged in? (ring/compojure)


what's the best way to route to one page if the user is signed in (i.e. session has a non-nil value for the user-id key) and another if the user is not signed in? The ideal would be 2 different set of routes.

Thanks!

Also, are there any good example apps using compojure out there?


Solution

  • Ok, so figured this out. Routes in compojure are composable, so you can take a defroutes handlers and feed it to another defroutes handler.

    http://vedang.me/techlog/2015/8/21/composability-and-compojure has a great explanation.