Created
March 15, 2012 15:02
-
-
Save dmozzy/2044670 to your computer and use it in GitHub Desktop.
GeoTaskList tutorial #2 core.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;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