Search code examples
google-app-engineclojurecompojureappengine-magic

Issues with getting both POST and GET http parameters in appengine-magic 0.4.3/Compojure 0.6.4


I'm having some serious issues with capturing POST and GET parameters with the latest appengine-magic/compojure versions. The parameters always come up as blank, even though the request object clearly has the right stuff in it.

I've seen some stuff around the interwebs about a change in the Compojure protocol where you have to manually put in the wrappers. I've tried this (using the handler/api wrapper to avoid the stuff in handler/site wrapper that breaks GAE) but it still doesn't work.

What am I doing wrong here?

My project.clj file:

(defproject pitch-filter "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.2.0"]
         [org.clojure/clojure-contrib "1.2.0"]
         [compojure "0.6.4"]
         [hiccup "0.3.6"]
         [jtidy "4aug2000r7-dev"]
         [commons-lang "2.5"]]
  :dev-dependencies [[appengine-magic "0.4.2"]
             [clj-http "0.1.1"]])

My core.clj file:

(ns pitch-filter.core
  (:use compojure.core
    [appengine-magic.multipart-params :only [wrap-multipart-params]]
    [hiccup.middleware :only (wrap-base-url)])
  (:require [pitch-filter.fetch :as fetch]
        [compojure.route :as route]
        [compojure.handler :as handler]
        [appengine-magic.core :as ae]
        [appengine-magic.services.url-fetch :as url]


(defroutes pitch-filter-app-routes
  (GET "/" [] "Main Page")
  (GET "/form" []
    (str "<form method='post' action='/post'>"
         "<input type='text' name='test'>"
         "<input type='submit'>"
         "</form>"))
  (POST "/post" {params :params}
    (pr-str params))
  (route/not-found "Page not found"))


(def pitch-filter-app-handler
     (-> pitch-filter-app-routes
     (handler/api)
     (wrap-base-url)
     ))

(ae/def-appengine-app pitch-filter-app #'pitch-filter-app-handler)

Solution

  • It certainly looks like dev_appserver.sh is busted with App Engine 1.5.1. Pity, but you aren't really supposed to use it with appengine-magic. You should use the interactive REPL tools (i.e., ae/serve). They work fine.

    I updated the ticket you opened on the appengine-magic project page (https://github.com/gcv/appengine-magic/issues/28).

    -gcv