Created
October 31, 2014 06:31
-
-
Save jeffmarshall/b85a3f5fa6fe0e307112 to your computer and use it in GitHub Desktop.
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
(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