Hi all,
I'm trying to use compojure and ring to parse POST data and haven't been able to figure out what I'm doing wrong.
I have some client-side clojure that takes a map literal, JSON encodes and URL encodes the result and puts it in an HTTP POST to my compojure/ring setup.
; e.g.
{:a "b"}
{"a":"b"}
data=%7B%22a%22%3A%22b%22%7D
When I do the POST, my server-side clojure doesn't parse the data={"a":"b"} but I know it's being sent because I did a packet capture to confirm the POST and "
posttestserver.com" successfully parses it (<- handy site - thanks Henry).
Below is my server-side stuff:
- - -
(ns my-ns.core
(:require [appengine-magic.core :as ae])
(:use [compojure.core :only [defroutes GET POST]])
(:use [ring.handler.dump :only [handle-dump]])
(:require [compojure.route :as route]))
(defroutes my-ns-app-handler
(POST "/admin/e2f/lineupload" {params :params} handle-dump)
(route/not-found "Page not found"))
(ae/def-appengine-app threadknow-app #'threadknow-app-handler)
- - -
And here is the result of handle-dump:
- - -
{:remote-addr "123.45.67.89",
:scheme :http,
:response
#<ResponseWrapper com.google.appengine.api.blobstore.dev.ServeBlobFilter$ResponseWrapper@24bfaa>,
:servlet #<app_servlet threadknow.app_servlet@1949f78>,
:request-method :post,
:query-string nil,
:route-params {},
:content-type "application/x-www-form-urlencoded",
:request #<Request POST /admin/e2f/lineupload HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Language: en-US
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.6.0_22
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 28
>,
:uri "/admin/e2f/lineupload",
:server-name "127.0.0.1",
:params {},
:headers
{"content-length" "28",
"connection" "keep-alive",
"accept" "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2",
"user-agent" "Java/1.6.0_22",
"pragma" "no-cache",
"cache-control" "no-cache",
"content-language" "en-US",
"content-type" "application/x-www-form-urlencoded"},
:content-length 28,
:server-port 8090,
:character-encoding nil,
:body #<Input org.mortbay.jetty.HttpParser$Input@8d3d62>,
:servlet-context
#<AppEngineServletContext ServletContext@1ed7ac{/,file:/home/rwaters/projects/my-ns/war/}>}
- - -
Thank you!