Skip to content

Instantly share code, notes, and snippets.

@alexott
Created May 13, 2012 09:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexott/2687096 to your computer and use it in GitHub Desktop.
Save alexott/2687096 to your computer and use it in GitHub Desktop.
Example of web-service for hashing
(ns hbr-clj
(:use compojure.core ring.middleware.reload clojure.data.json)
(:require [compojure.route :as route])
(:import [org.apache.commons.codec.digest DigestUtils]))
(defroutes my-routes
(GET "/md5/:what" [what] (json-str {:what what :hash (DigestUtils/md5Hex what)}))
(route/not-found "<h1>Page not found</h1>"))
(def app (-> #'my-routes
(wrap-reload '[hbr-clj])))
(defproject hbr-clj "0.0.1"
:description "Example of web service"
:dependencies [[org.clojure/clojure "1.3.0"]
[compojure "1.0.4"]
[org.clojure/data.json "0.1.2"]
[commons-codec "1.6"]]
:dev-dependencies [[lein-ring "0.6.1"]]
:ring {:handler hbr-clj/app}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment