Conditional routing?

Hello!

I have a question about routing rules - is it possible to do a conditional routing, with a condition based on a request’s parameters (like session id presence or some session attribute)?

Examples of what I would like to achieve:

  • if a user isn’t logged in, redirect to a login page
  • choose an endpoint based on a user’s role (“green users” see one UI/content, while “blue users” see a different UI/content)

Maybe such goals are achieved differently in Hanami, but a switch inside routing rules seems quite natural to me.
Anyway, I’ll be glad for any suggestion!