Skip to content

Instantly share code, notes, and snippets.

@jeffmarshall
Created October 31, 2014 06:31
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 jeffmarshall/b85a3f5fa6fe0e307112 to your computer and use it in GitHub Desktop.
Save jeffmarshall/b85a3f5fa6fe0e307112 to your computer and use it in GitHub Desktop.
(ns causemap-parse.handler
(:require [compojure.core :refer :all]
[compojure.handler :as handler]
[compojure.route :as route]
[ring.middleware.cors :refer [wrap-cors]]
[ring.util.response :refer [resource-response response]]
[ring.middleware.json :as middleware]
[duckling.core :as p]))
(p/load!) ;; Load default configuration
(defroutes app-routes
(POST "/" request (response (p/parse :en$core ;; core configuration for English ; see also :fr$core, :es$core, :cn$core
(get-in request [:body :period])
[:time])))
(route/resources "/")
(route/not-found "Not Found"))
(def app
(-> (handler/site app-routes)
(wrap-cors :access-control-allow-origin #"http://www.causemap.org"
:access-control-allow-methods [:post])
(middleware/wrap-json-body {:keywords? true})
(middleware/wrap-json-response)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment