在 appengine-magic 0.4.3/Compojure 0.6.4 中获取 POST 和 GET http 参数时出现问题

发布于 2024-11-19 11:25:07 字数 1602 浏览 2 评论 0原文

我在使用最新的 appengine-magic/compojure 版本捕获 POST 和 GET 参数时遇到一些严重问题。尽管请求对象中显然包含正确的内容,但参数始终显示为空白。

我在互联网上看到了一些关于 Compojure 协议更改的内容,您必须手动放入包装器。我已经尝试过这个(使用处理程序/api 包装器来避免处理程序/站点包装器中的内容破坏 GAE),但它仍然不起作用。

我在这里做错了什么?

我的project.clj 文件:

(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"]])

我的core.clj 文件:

(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)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终难愈 2024-11-26 11:25:07

看起来 dev_appserver.sh 确实被 App Engine 1.5.1 破坏了。遗憾的是,您实际上不应该将它与 appengine-magic 一起使用。您应该使用交互式 REPL 工具(即 ae/serve)。他们工作得很好。

我更新了您在 appengine-magic 项目页面 (https://github.com/gcv/appengine-magic/issues/28) 上打开的票证。

-gcv

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

拔了角的鹿 2024-11-26 11:25:07

事实证明,此问题仅在使用 Google App Engine 1.5.1 dev_appserver.sh 时发生。它与 1.4.3 配合得很好。我会将其保留,以防其他人找到更好的解决方案。

Turns out that this issue only happens when using the Google App Engine 1.5.1 dev_appserver.sh. It works fine with 1.4.3. I'll leave this open in case someone else finds a better solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文