Created
July 10, 2010 02:37
-
-
Save swannodette/470367 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 second-post.couchdb | |
(:use aleph | |
[clojure.contrib.json :only [read-json json-str]]) | |
(:require [com.twinql.clojure.http :as http]) | |
(:import [org.apache.http HttpEntity] | |
[org.apache.http.entity StringEntity])) | |
(defn ^HttpEntity json->entity [json] | |
(StringEntity. (json-str json))) | |
(defn create-document [doc] | |
(http/post "http://localhost:5984/dummy" | |
:headers {"Content-Type" "application/json"} | |
:body (json->entity doc))) | |
(defn save [request] | |
(future | |
(create-document {:bar "test"}) | |
(respond! request | |
{:status 200 | |
:headers {"Content-Type" "text/html"} | |
:body "Hello world!"}))) | |
(run-aleph save {:port 8080}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment