Creating the recently added route
Before we can view a page, we have to be able to serve it. We'll be creating a couple of album-related pages in hipstr. So let's create a new hipstr.routes.albums
namespace, and also create a route to serve up a page for the /albums/recently-added
URL:
Create a new
hipstr.routes.albums
namespace in thehipstr/routes
directory. As with our other route namespaces, we'll be making use of Compojure for creating the route, as well asalbum-model
to retrieve the recently added albums from the database:(ns hipstr.routes.albums (:require [compojure.core :refer :all] [hipstr.layout :as layout] [hipstr.models.album-model :as album]))
Next, we'll define a new
album-routes
defroute that will encapsulate all our albums-related routes for hipstr:(defroutes album-routes (GET "/albums/recently-added" [] (album/get-recently-added)))
Finally, we have to add the new
album-routes
to the hipstrapp-handler
:Open the
hipstr/handler.clj
file and add a reference...