May 2018
Beginner to intermediate
290 pages
6h 43m
English
A great way to get a feel for working with multiple threads in Clojure is to look at the Compojure library.[30] Compojure helps you route the requests that come into your web application to a suitable response. Here, for example, is a simple placeholder web application for our book store, built with Compojure:
| | (ns storefront.handler |
| | (:require [compojure.core :refer :all] |
| | [compojure.handler :as handler])) |
| | |
| | (defroutes main-routes |
| | (GET "/" [] "Welcome to Blotts Books!!") |
| | (GET "/book" [title author] |
| | (str "Sorry " title " By " author " is not available."))) |
| | |
| | (def app (handler/site main-routes)) |
The key bit of code here is the call to defroutes, which allows you to associate a route—/book, for example—with ...
Read now
Unlock full access