Services

We’ll factor out the API endpoints from the guestbooks.routes.home into a separate guestbook.routes.services namespace. The endpoints in the home namespace will be responsible for serving HTML and related assets to be used by the web browser to render the page. Meanwhile, the services namespace will provide a data API (for example, JSON, EDN, and others) to be used by the client over Ajax.

The key motivation for separating our page rendering code and the API endpoints is to facilitate maintainability. Keeping all of our logic in one place has been manageable so far, but it will require discipline to keep things organized as our application grows. We should separate our model logic early so that it doesn’t become entangled with our ...

Get Web Development with Clojure, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.