Skip to content

Instantly share code, notes, and snippets.

@wmacgyver
Created July 27, 2010 03:30
Show Gist options
  • Save wmacgyver/491678 to your computer and use it in GitHub Desktop.
Save wmacgyver/491678 to your computer and use it in GitHub Desktop.
(ns mywebapp.firstservlet
(:use [ring.util.servlet :only (defservice)])
(:use ring.middleware.stacktrace)
(:use compojure.core)
(:use mywebapp.add)
(:gen-class
:extends javax.servlet.http.HttpServlet))
(defn parse-input [a b]
[(Integer/parseInt a) (Integer/parseInt b)])
(defn render [t]
(apply str t))
(defroutes handler
(GET "/webexample/" [] "top level")
(GET "/webexample/view" [] (render (add-two-nums-noanswer)))
(GET "/webexample/add" [a b] (let [[a b] (parse-input a b)] (render (add-two-nums a b))))
(GET "/webexample/addjson" [a b] (let [[a b] (parse-input a b)] (add-two-nums-json a b)))
(GET "/webexample/addxml" [a b] (let [[a b] (parse-input a b)] (add-two-nums-xml a b)))
(ANY "/*" [] "not found"))
(def app
(-> #'handler
(wrap-stacktrace)))
(defservice app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment