We’ll factor out the API endpoints from the guestbooks.routes.home into a separate 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 the O’Reilly learning platform.

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