Skip to content

Instantly share code, notes, and snippets.

@ekhall
Created June 9, 2014 21:55
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 ekhall/bf93f8cc420e26a6c8b0 to your computer and use it in GitHub Desktop.
Save ekhall/bf93f8cc420e26a6c8b0 to your computer and use it in GitHub Desktop.
(defn wrap-dump [handler]
(let [out-writer (java.io.FileWriter. "output.html")]
(fn [request]
(binding [*out* out-writer] (prn request))
(let [response (handler request)]
(binding [*out* out-writer] (prn response))
response))))
(def app
(-> (wrap-simulated-methods routes)
(wrap-params)
(wrap-db)
(wrap-resource "static")
(wrap-file-info)
(wrap-server-name)
(wrap-dump)))
{:ssl-client-cert nil, :remote-addr "0:0:0:0:0:0:0:1", :headers {"accept-encoding" "gzip,deflate,sdch", "cache-control" "max-age=0", "connection" "keep-alive", "user-agent" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36", "accept-language" "en-US,en;q=0.8", "accept" "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "host" "localhost:8000", "dnt" "1", "cookie" "JSESSIONID=eg58v66vcybj11s10u8dc9f4a"}, :server-port 8000, :content-length nil, :content-type nil, :character-encoding nil, :uri "/items", :server-name "localhost", :query-string nil, :body #<HttpInput org.eclipse.jetty.server.HttpInput@2f61018a>, :scheme :http, :request-method :get}
{:status 200, :headers {"Server" "Datomickev"}, :body "<!DOCTYPE html>\n<html lang=\"en\"><head><title>Kevtronica</title><meta content=\"width=device-width, initial-scale=1.0\" name=\"viewport\"><link href=\"/bootstrap/css/bootstrap.min.css\" rel=\"stylesheet\"></head><body><div class=\"container\"><h1>My Items</h1><div class=\"row\"><table class=\"table table-striped\"><thead><tr><th class=\"col-sm-2\"></th><th class=\"col-sm-2\"></th><th>Name</th><th>Description</th><th>Datomic Entity ID</th></tr></thead><tbody><tr><td>{:item/name \"First Item\", :item/description \"This is the first item\", :item/active true, :db/id 277076930200554}</td><td><form action=\"/items/277076930200554\" method=\"POST\"><input name=\"_method\" type=\"hidden\" value=\"DELETE\" /><div class=\"btn-group\"><input class=\"btn btn-danger btn-xs\" type=\"submit\" value=\"Delete\" /></div></form></td><td><form action=\"/items/277076930200554\" method=\"POST\"><input name=\"_method\" type=\"hidden\" value=\"PUT\" /><input name=\"checked\" type=\"hidden\" value=\"true\" /><div class=\"btn-group\"><button class=\"btn btn-primary btn-xs\">TODO</button></div></form></td><td>First Item</td><td>This is the first item</td><td>277076930200554</td></tr><tr><td>{:item/name \"second\", :item/description \"sdoncsd fsodf\", :item/active true, :db/id 277076930200557}</td><td><form action=\"/items/277076930200557\" method=\"POST\"><input name=\"_method\" type=\"hidden\" value=\"DELETE\" /><div class=\"btn-group\"><input class=\"btn btn-danger btn-xs\" type=\"submit\" value=\"Delete\" /></div></form></td><td><form action=\"/items/277076930200557\" method=\"POST\"><input name=\"_method\" type=\"hidden\" value=\"PUT\" /><input name=\"checked\" type=\"hidden\" value=\"true\" /><div class=\"btn-group\"><button class=\"btn btn-primary btn-xs\">TODO</button></div></form></td><td>second</td><td>sdoncsd fsodf</td><td>277076930200557</td></tr></tbody></table></div><div class=\"col-sm-8\"><h2>Create a new item</h2><form action=\"/items\" class=\"form-horizontal\" method=\"POST\"><div class=\"form-group\"><label class=\"control-label col-sm-2\" for=\"name-input\">Name</label><div class=\"col-sm-10\"><input class=\"form-control\" id=\"name-input\" name=\"name\" placeholder=\"Name\" /></div></div><div class=\"form-group\"><label class=\"control-label col-sm-2\" for=\"desc-input\">Description</label><div class=\"col-sm-10\"><input class=\"form-control\" id=\"desc-input\" name=\"description\" placeholder=\"Description\" /></div></div><div class=\"form-group\"><div class=\"col-sm-offset-2 col-sm-10\"><input class=\"btn btn-primary\" type=\"submit\" value=\"New item\" /></div></div></form></div></div><script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js\"></script><script src=\"/bootstrap/js/bootstrap.min.js\"></script></body></html>"}
{:ssl-client-cert nil, :remote-addr "0:0:0:0:0:0:0:1", :headers {"host" "localhost:8000", "user-agent" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36", "cookie" "JSESSIONID=eg58v66vcybj11s10u8dc9f4a", "referer" "http://localhost:8000/items", "connection" "keep-alive", "if-modified-since" "Thu, 13 Feb 2014 17:24:42 +0000", "accept" "text/css,*/*;q=0.1", "accept-language" "en-US,en;q=0.8", "accept-encoding" "gzip,deflate,sdch", "dnt" "1", "cache-control" "max-age=0"}, :server-port 8000, :content-length nil, :content-type nil, :character-encoding nil, :uri "/bootstrap/css/bootstrap.min.css", :server-name "localhost", :query-string nil, :body #<HttpInput org.eclipse.jetty.server.HttpInput@2f61018a>, :scheme :http, :request-method :get}
{:ssl-client-cert nil, :remote-addr "0:0:0:0:0:0:0:1", :headers {"host" "localhost:8000", "user-agent" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36", "cookie" "JSESSIONID=eg58v66vcybj11s10u8dc9f4a", "referer" "http://localhost:8000/items", "connection" "keep-alive", "if-modified-since" "Thu, 13 Feb 2014 17:24:42 +0000", "accept" "*/*", "accept-language" "en-US,en;q=0.8", "accept-encoding" "gzip,deflate,sdch", "dnt" "1", "cache-control" "max-age=0"}, :server-port 8000, :content-length nil, :content-type nil, :character-encoding nil, :uri "/bootstrap/js/bootstrap.min.js", :server-name "localhost", :query-string nil, :body #<HttpInput org.eclipse.jetty.server.HttpInput@5ad5c40d>, :scheme :http, :request-method :get}
{{:status:status 304304, , :headers :headers {"{Server"" "SDeartvoemri"c kev"", Da"tCoomnitceknetv"-T, ype" "C"otnetxetn/tc-sTsy"p, e" ""Ltaesxtt-/Mjoadviafsicerdipt"", ""TLhaus,t -1M3o dFiefbi e2d0"1 4 1"7T:h2u4,: 4123 +F0e0b0 02"0, 14 17":C2o4n:t4e2n t+-0L0e0n0g"t, h" ""C0o"nt}ent, -Lengt:bodyh " """}0"}, :body ""}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment