Clojure from zero to hero (0) - creating a Pedestal app

Jun 18, 2019

(ns com.georgeracu.site.posts.fzth.zero)

Install Leiningen and create your first app

Clojure

Clojure is a dynamic, general-purpose programming language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming.

Leiningen

As these folks are saying on their website: If you come from the Java world, Leiningen could be thought of as “Maven meets Ant without the pain”. For Ruby and Python folks, Leiningen combines RubyGems/Bundler/Rake and pip/Fabric in a single tool.

Basically is a dependency management tool with built in capabilities to build the Clojure project and to generate Clojure apps from templates.

Install Leiningen

Ubuntu 19.04

sudo apt install leiningen

Homebrew

brew install leiningen

If you have a different distro or a different operating system, go to Leiningen’s instalation instructions and you should find instructions on how to do it.

Pedestal

Pedestal is a set of libraries that we use to build services and applications. It runs in the back end and can serve up whole HTML pages or handle API requests.

First Clojure project

Create a new web API from a template

lein new pedestal-service pedestal-api

Go to the new location and tell Leiningen to download and install all the dependencies for the project

cd pedestal-api
lein deps

Run the application using Leiningen

lein run

Navigate to http://localhost:8080 and you should get the very popular greeting “Hello world”.

Don’t forget to version your code

I am using git to version my code. I presume you already know what git is and what code versioning means and you also have git installed. Therefore I would urge you to start tracking your code:

git add .
git commit -m "Initial commit, created a default project."

Grab a drink to celebrate

Done, you have a running web API using Clojure, Pedestal and Leiningen.

Tags: programmingclojure

Archives

  1. February 2024
  2. Maximizing Software Development Productivity: The Power of Flow and Minimizing Interruptions
  3. December 2023
  4. Clean Code in Java: Writing Code that Speaks
  5. Clean Code in Java: A concise guide
  6. Understanding Value Objects in Java: A Brief Guide
  7. August 2023
  8. Consuming RabbitMQ Messages with Clojure: A Step-by-Step Tutorial with Tests
  9. January 2023
  10. Running a Spring Boot service with kubernetes
  11. December 2022
  12. Hosting a PWA with Jekyll and Github pages
  13. November 2022
  14. Global Day of Code Retreat
  15. Facilitating a mini Code Retreat
  16. October 2022
  17. The Curse of Optional
  18. September 2022
  19. Testing Spring Boot Microservices - Presentation
  20. March 2022
  21. TDD Workshop
  22. February 2022
  23. Value Objects in Java
  24. Efficient Java
  25. January 2022
  26. Spring Boot testing - Focus on your changes
  27. Product users - Personas
  28. December 2021
  29. Write code fit for testing
  30. November 2020
  31. Running a Spring Boot app with kubernetes
  32. September 2019
  33. Setup GPG on Mac and sign git repositories
  34. July 2019
  35. Running a Clojure Pedestal application on Raspberry Pi model B revision 2
  36. Clojure from zero to hero (part 3) - First endpoint
  37. Clojure from zero to hero (part 2) - A bit of syntax
  38. June 2019
  39. Clojure from zero to hero (1) - explaining project.clj
  40. Clojure from zero to hero (0) - creating a Pedestal app
  41. November 2017
  42. Introduction to Docker
  43. April 2015
  44. Git micro commits
  45. July 2014
  46. Google Glass Development - setup tools, environment and turn on debugging on Glass
  47. June 2013
  48. How To: Get the rendered HTML of a webpage with Python
  49. Set union of two lists in Python