Created
January 16, 2009 17:52
-
-
Save wilkes/48036 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 org.buntin.github.github | |
(:require [org.danlarkin.json :as json]) | |
(:import [org.apache.http.impl.client DefaultHttpClient] | |
[org.apache.http.client.methods HttpGet] | |
[org.apache.http.util EntityUtils])) | |
(def user "%s") | |
(def search "search/%s") | |
(def commit "%s/%s/commit/%s") | |
(def recent "%s/%s/commits/%s") | |
(defn- response->json [response] | |
(json/decode-from-str (EntityUtils/toString (.getEntity response)))) | |
(defn- perform-request [url] | |
(response->json (.execute (DefaultHttpClient.) (HttpGet. url)))) | |
(defn gh-client [version type] | |
(fn [format-string & args] | |
(perform-request (apply format | |
(str "http://github.com/api/%s/%s/" format-string) | |
version type args)))) | |
(comment | |
(def *gh* (gh-client "v1" "json")) | |
(*gh* user "sethtrain") | |
(*gh* recent "sethtrain" "authorize-clj" "master") | |
(*gh* search "clojure") | |
(*gh* commit "sethtrain" "authorize-clj" "a2771c6db5cc6c034c617374c239d0ae6c351d6f")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment