Building web applications with Clojure - code
Please note, that this code is provided for demonstrational purposes only and was written live during short videos. Therefore, it is kind of pointless to use it without commentary provided in the video course itself.
Each video has a separate git tag for version of code available at the end of it, so you can walk through the progress of the tutorials or jump to the one you're currently browsing.
For example, video 2 of section 3, is tagged as SECTION3_VIDEO2, which video 1 of section 5 is tagged as SECTION5_VIDEO1.
Each section and video is described below, so you can easily browse the code and access external links to tools and libraries mentioned in each video.
Feel free to fork and play around with this repo!
Section 1: Getting Started
In this section, the reader will learn how to create a Leiningen project, configure Ring dependencies and plugins and start the web server from a command line.
- Video 1: project setup
- Video 2: lein-ring plugin
- Video 3: simple Ring handler
- Video 4: running Ring server
- Video 5: building web application packages
Section 2: Ring Handlers
This section will explain how handlers in Ring work, what do they do and how we can access HTTP request manipulate an HTTP response. We will also see how to dispatch calls to different functions and introduce general mechanisms.
- Video 1: Ring handler anatomy
- Video 2: request map
- Video 3: response map
- Video 4: routing
- Video 5: not found and error handling
Section 3: Middleware
In this section, I will explain how Ring middleware works. Then, I will implement an example middleware. Finally, use of existing middleware will be shown.
- Video 1: introduction
- Video 2: example
- Video 3: altering request and response
- Video 4: using existing middleware
Section 4: Forms & sessions handling
In this section, I will show to handle POST/GET parameters from Clojure web application, generate HTML content from Clojure level, manipulate cookies and manage Ring sessions.
- Video 1: Form handling
- Video 2: Generating HTML content
- Video 3: Manipulating cookies
- Video 4: Ring sessions
Section 5: Building RESTful API
This section will show how we can easily build a RESTful, JSON-based API with Clojure/Ring.
- Video 1: API introduction and routing
- Video 2: Example RESTful API
- Video 3: Handling errors in REST API
Section 6: Database connectivity
In this section, I will showcase how can we integrate a popular databases - PostgreSQL and MongoDB with Clojure web app. For PostgreSQL, popular Clojure ORM framework - Korma, will be introduced.
Section 7: ClojureScript
- Video 1: ClojureScript
- Video 2: Manipulating DOM tree with ClojureScript
- Video 3: Accessing REST API from ClojureScript
Section 8: Useful web libraries in Clojure
In this section, I will show most popular and useful web libraries available for Clojure - Compojure for routing, Hiccup and Enlive for HTML templating and Liberator for building RESTful APIs.