사용 라이브러리
- ring(http)
- compojure(라우팅)
- ring-json (clojure의 map 을 json 응답으로 만들어준다)
콘솔에 lein new compojure PROJECT_NAME 을 입력하면 ring 과 compojure 기반의 프로젝트 템플릿이 생성된다.
프로젝트 폴더 구성은 다음과 같다.

handler.clj 의 소스코드는 다음과 같다.
(ns cheshire-cat.handler
(:require [compojure.core :refer :all]
[compojure.route :as route]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
[ring.middleware.json :as ring-json]
[ring.util.response :as rr]))
(defroutes app-routes
(GET "/" [] (rr/response {:name "home" :status "good"}))
(GET "/cheshire" [] (rr/response
{:name "Cheshire cat"
:status :grinning}))
(route/not-found "Not Found"))
(def app
(-> app-routes
(ring-json/wrap-json-response)
(wrap-defaults site-defaults)))
각 라우팅 / 과 /cheshire 에 대해 json 응답을 하는 api 서버 코드 작성 끝.
배포는 aws beanstalk 를 사용할 것이다.
lein-beanstalk 라고 beanstalk 배포를 자동으로 해주는 CLI 라이브러리가 있는데, No Solution Stack named '32bit Amazon Linux running Tomcat 7' found. 라는 에러를 내뱉는다.
aws 가 더이상 32비트 리눅스 서버를 지원 안하는듯.
좀 오래된 라이브러리라서 그런지 최신환경에서는 작동을 안하는 것 같다 (가장 마지막 commit 이 7년전).





