Fork me on GitHub
Ion Simion15:08:40

I guess the question resumes to - how can I implement Reitit to use a query param as the routes base: *?route=* /page/subpage “/” may get encoded so perhaps also use a different path separator?


I don’t know if that is possible to do with reitit, maybe it is, it sounds very interesting. You don’t happen to have a reverse proxy, do you? In my case I use nginx so I would probably solve this in nginx with a rewrite rule.


Maybe you’ve already solved this, but I had another thought about it. And maybe you’ve already considered this approach; perhaps you are already doing something like this and you were hoping to find a way to have reitit do it for you, so apologies if this is not helpful to you. (It was helpful to me, because I’m considering serving multiple domains from the same app, and I might need to do something similar to what I mention below, which I guess could be summarized as “routing based on something more than just the :uri, whether that be based on fragments, :server-name, :query-str, :headers, something else, etc.) Basically, my thought was you could add custom middleware to intercept and alter requests before passing them to the reitit-generated ring-router. This isn’t much different from what I suggested before using rewrite rules, but instead of doing it externally in your reverse proxy server, you do it in Clojure with custom middleware. Something like this:

(def frag-middleware [handler]
  (fn [request]
    (let [modified-request (modify-request-based-on-frag request)]
      (handler modified-request))))

(def app
      ["/page/subpage" {:get get-handler, :post post-handler}])
    {:middleware [frag-middleware]}))

👀 1
Ion Simion18:08:37

Thank you for your time and the extended description, will try this definitely! I have no server control, is a widget with routing that clients incorporate in front-end UI