Skip to content
Snippets Groups Projects
Commit 1a4ff6e5 authored by Cam Saul's avatar Cam Saul
Browse files

Basic boilerplate for Compojure/Ring HTTP server;

add some deps we will definitely want or need
parent 3b3a3866
Branches
Tags
No related merge requests found
......@@ -8,9 +8,9 @@ Download from http://example.com/FIXME.
## Usage
FIXME: explanation
Run the HTTP server with
$ java -jar metabase-init-0.1.0-standalone.jar [args]
lein ring server
## Documentation
......
;; -*- comment-column: 60; -*-
(defproject metabase "metabase-0.1.0-SNAPSHOT"
:description "Metabase Community Edition"
:url "http://metabase.com/"
......@@ -5,25 +7,36 @@
:url "http://www.eclipse.org/legal/epl-v10.html"}
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.6.0"]
[expectations "2.0.12"] ; unit tests
[marginalia "0.7.1"] ; for documentation
[environ "0.5.0"] ; easy environment management
[org.clojure/tools.logging "0.3.1"] ; logging framework
[log4j/log4j "1.2.17" :exclusions [javax.mail/mail
javax.jms/jms
com.sun.jdmk/jmxtools
com.sun.jmx/jmxri]]
[com.h2database/h2 "1.3.170"] ; embedded SQL database
[korma "0.4.0"] ; SQL lib
[org.clojure/core.async "LATEST"] ; facilities for async programming + communication (using 'LATEST' because this is an alpha library)
[org.clojure/core.match "0.3.0-alpha4"] ; optimized pattern matching library for Clojure
[org.clojure/data.json "0.2.5"] ; JSON parsing / generation
[org.clojure/tools.logging "0.3.1"] ; logging framework
[org.clojure/tools.macro "0.1.2"] ; tools for writing macros
[com.cemerick/friend "0.2.1"] ; auth library
[com.h2database/h2 "1.3.170"] ; embedded SQL database
[compojure "1.3.1"] ; HTTP Routing library built on Ring
[environ "0.5.0"] ; easy environment management
[expectations "2.0.12"] ; unit tests
[korma "0.4.0"] ; SQL lib
[log4j/log4j "1.2.17"
:exclusions [javax.mail/mail
javax.jms/jms
com.sun.jdmk/jmxtools
com.sun.jmx/jmxri]]
[marginalia "0.7.1"] ; for documentation
[ring/ring-json "0.3.1"] ; Ring middleware for reading/writing JSON automatically
[swiss-arrows "1.0.0"] ; 'Magic wand' macro -<>, etc.
]
:plugins [[cider/cider-nrepl "0.8.2"] ; Interactive development w/ cider NREPL in Emacs
[lein-environ "0.5.0"] ; easy access to environment variables
[lein-expectations "0.0.7"] ; run unit tests with 'lein expectations'
[lein-midje "3.1.3"] ; another unit testing option
[lein-marginalia "0.7.0"] ; generate documentation with 'lein marg'
:plugins [[cider/cider-nrepl "LATEST"] ; Interactive development w/ cider NREPL in Emacs
[lein-environ "0.5.0"] ; easy access to environment variables
[lein-expectations "0.0.7"] ; run unit tests with 'lein expectations'
[lein-midje "3.1.3"] ; another unit testing option
[lein-marginalia "LATEST"] ; generate documentation with 'lein marg'
[lein-ring "0.8.10"] ; start the HTTP server with 'lein ring server'
]
:main ^:skip-aot metabase.core
:target-path "target/%s"
:ring {:handler metabase.core/app}
:profiles {:dev {:dependencies [[midje "1.6.3"]]
:jvm-opts ["-Dlogfile.path=target/log"]}
:uberjar {:aot :all}})
(ns metabase.core
(:gen-class)
(:require [clojure.tools.logging :as log]))
(:require [clojure.tools.logging :as log]
[compojure.core :refer [context defroutes GET]]
[compojure.route :as route]
[ring.middleware.json :refer [wrap-json-response]]))
(defn -main
"I don't do a whole lot ... yet."
......@@ -9,6 +12,16 @@
(log/info "testing logging"))
(defn first-element [sequence default]
(if (nil? sequence)
default
(first sequence)))
\ No newline at end of file
(or (first sequence) default))
(defroutes routes
(GET "/" [] "Success!")
(GET "/test.json" [] {:status 200
:body {:message "We can serialize JSON <3"}})
(route/not-found "404 :/"))
(def app
"The primary entry point to the HTTP server"
(-> routes
wrap-json-response ; middleware to automatically serialize suitable objects as JSON in responses
))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment