开发者

compojure 0.6.0: problem getting post arguments with google app engine

This is how I define my app:

(defroutes index
   (GET "/" [] (main-page))
   (GET "/form" [] (render-page "Vote" (render-form)))开发者_Go百科
   (POST "/vote" {params :params} (post-vote params))
   (route/not-found "Page not found"))

(def app (site index))

(defservice app)

The site here is used to capture :params, which is a new in compojure 0.6.0. However I'm getting a empty map in post-vote. I wonder what's wrong with the above code?


If you are running this on google app engine, I don't think you can use the (site) convenience function as it includes ring's (wrap-multipart-params) function which uses a java class not permitted by google.

Unless you are uploading a file from your form, you probably don't need multipart-params. Try removing compojure.handler from your namespace and replacing your (def app (site index)) with something like:

(def app
     (-> index
     (wrap-keyword-params)
     (wrap-nested-params)
     (wrap-params)))

Cheers, Colin


as I replied in the mailing-list, please ensure, that your form is really sending the params (input controls in html form have to have name="..." attribute)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜