Skip to content

Instantly share code, notes, and snippets.

@dmozzy
Created March 15, 2012 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmozzy/2044670 to your computer and use it in GitHub Desktop.
Save dmozzy/2044670 to your computer and use it in GitHub Desktop.
GeoTaskList tutorial #2 core.clj
;Follow the blog posts for this code here: http://www.digitalbricklayers.com/2012/03/geotasklist-part-2.html
(ns GeoTaskList.core
(:require [appengine-magic.core :as ae]
[compojure.route :as route])
(:use [compojure.core]
[cheshire.core :as json]
[ring.util.response :as ring-response]
[compojure.handler :as comp-handler]
[GeoTaskList.persistence :as persist]))
(defn json-response [data & [status]]
{:status (or status 200)
:headers {"Content-Type" "application/json"}
:body (json/generate-string data)})
(defroutes geotasklist-main-handler
;Get All Locations Routes
(GET "/locations" []
(json-response {:locations (get-all-locations)}))
;Delete Location Route
(POST "/delete-location" {params :params}
(println (:locationId params))
(json-response (delete-location (Integer/parseInt (:locationId params)))))
;Update Location Route
(POST "/location" {params :params}
(json-response {:locationId (persist/save-location params)}))
;Static Resources
(route/resources "/")
(route/not-found "Page not found"))
(def app (comp-handler/api geotasklist-main-handler))
(ae/def-appengine-app geotasklist-app (var app))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment