Skip to content

Instantly share code, notes, and snippets.

@dmozzy
Created March 11, 2012 07:37
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/2015449 to your computer and use it in GitHub Desktop.
Save dmozzy/2015449 to your computer and use it in GitHub Desktop.
GeoTaskList tutorial #1 core.clj
;Read the blog post on this gist here http://www.digitalbricklayers.com/2012/03/geotasklist-in-jquery-mobile-and.htm
(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]))
(defn json-response [data & [status]]
{:status (or status 200)
:headers {"Content-Type" "application/json"}
:body (json/generate-string data)})
(def test-location-1 {:name "Hardware" :lat -31.957242 :lng 115.931422})
(def test-location-2 {:name "Mall" :lat -31.964779 :lng 115.935241})
(def test-locations (list test-location-1 test-location-2))
(defroutes geotasklist-main-handler
(GET "/locations" []
(json-response {:locations test-locations}))
(GET "/location/:id" [id]
(json-response (nth test-locations id)))
(route/resources "/")
(route/not-found "Page not found"))
(ae/def-appengine-app geotasklist-app #'geotasklist-main-handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment