Created
September 24, 2014 18:36
-
-
Save superchris/4694be80f1aabcc2513c to your computer and use it in GitHub Desktop.
Clojure twitter search spike
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 acme.handler | |
(:require [compojure.core :refer :all] | |
[twitter.oauth :as oauth] | |
[compojure.handler :as handler] | |
[compojure.route :as route] | |
[twitter.api.search :as twitter] | |
[ring.util.response :refer [resource-response response]] | |
[ring.middleware.json :as middleware] | |
)) | |
(def my-creds (oauth/make-oauth-creds "7kF64LO6VNVVo5fIxg9zyA" | |
"Ub2fVtL2zzqk63djJYZHHBTJS1ilVt28B7BCnOj6GM" nil nil)) | |
(defroutes app-routes | |
(GET "/" [] "Hello everbody!!") | |
(GET "/tweets/:term" [term] | |
(response (twitter/search :oauth-creds my-creds :params {:q term}))) | |
(route/resources "/") | |
(route/not-found "Not Found")) | |
(def app | |
(-> | |
(handler/site app-routes) | |
(middleware/wrap-json-body) | |
(middleware/wrap-json-response))) |
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
(defproject acme "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:dependencies [[org.clojure/clojure "1.6.0"] | |
[compojure "1.1.8"] | |
[twitter-api "0.7.6"] | |
[ring/ring-json "0.2.0"] | |
[ring/ring-core "1.2.0"] | |
] | |
:plugins [[lein-ring "0.8.11"]] | |
:ring {:handler acme.handler/app} | |
:profiles | |
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"] | |
[ring-mock "0.1.5"]]}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment