Chapter 4. URL Routing and Template Rendering

So far, we've looked at the basics of getting our codebase into a state where we can start developing some of the meat of our application. It hasn't been very exciting, I know. In this chapter, however, we will start building our application, creating actual endpoints that process HTTP requests, which return something we can look at. In this chapter, we will:

  • Learn what the Compojure routing library is and how it works
  • Build our own Compojure routes to handle an incoming request
  • Learn what the Selmer rendering library is and how it works
  • Create our own Selmer HTML template

    Note

    What this chapter won't cover, however, is making any of our HTML pretty, client-side frameworks, or JavaScript. Our goal is to understand the server-side/Clojure components and get up and running as quickly as possible. As a result, our templates are going to look pretty basic, if not downright embarrassing.

What is Compojure?

Compojure is a small, simple library that allows us to create specific request handlers for specific URLs and HTTP methods. In other words, "HTTP Method A requesting URL B will execute Clojure function C". By allowing us to do this, we can create our application in a sane way (URL-driven), and thus architect our code in some meaningful way.

Note

For the studious among us, the Compojure docs can be found at https://github.com/weavejester/compojure/wiki.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.157.142