0

I would like to make a Luminus app that provides a REST API and serves data from that API in Selmer templates. However, I can't figure out how to get the routing to work.

For example, if you create a luminus template using the command lein new luminus consume_rest +reitit +swagger, you'll get selmer templates under home-routes and the REST API under service-routes. I would like to include data provided by endpoints under service routes within the templates in home-routes.

Does anyone have a suggested way on how to architect this, or an example of an application that does so? Every project I`ve seen with a REST API is a SPA using clojurescript, which call the REST API with AJAX.

  • Would you clarify why you want this? Typically, the data returned by `home-routes` and selmer is HTML and is for human consumption. Typically, the data returned by an API under `service-routes` is meant for machine consumption and it usually will be JSON or EDN or XML or some such format. Mixing the two seems like a bad architectural choice. – dorab Feb 14 '22 at 00:06
  • I'd like to have an API so that I have the flexibility to swap out selmer or add mobile clients in the future. – Unsatisfied Zebra Feb 14 '22 at 09:25
  • 1
    You could make another namespace for defining all clojure apis, define similar routes in service-routes and home-routes and call the clojure apis from routes handlers. Data will be consistent, and in home-routes handler you can pass this data into relevant template. Have you tried structuring like this? – Shivam Feb 20 '22 at 12:02

0 Answers0