O'Reilly logo

Clojure Web Development Essentials by Ryan Baldwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Compojure route

Let's do an example that will allow the awful sounding tech jargon to make sense. We will create an extremely basic route, which will simply print out the original request map to the screen. Let's perform the following steps:

  1. Open the home.clj file.
  2. Alter the home-routes defroute such that it looks like this:
    (defroutes home-routes
      (GET "/" [] (home-page))
      (GET "/about" [] (about-page))
      (ANY "/req" request (str request)))
  3. Start the Ring Server if it's not already started.
  4. Navigate to http://localhost:3000/req.

    Note

    It's possible that your Ring Server will be serving off a port other than 3000. Check the output on lein ring server for the serving port if you're unable to connect to the URL listed in step 4.

You should see something ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required