You need to make sure your handler has the wrap-params middleware applied
to it in order for it to accept query parameters.

- James


On 12 July 2014 20:41, Jonathon McKitrick <jmckitr...@gmail.com> wrote:

> I'm using ring.mock.request to test an API.  POST parameters work fine,
> but for GET requests, the parameters are not where Compojure expects to
> find them.
>
> Here is the relevant part of the handler:
>
> (GET "/outlines" [speaker :as r]
>                 (println (str "Request " r))
>                 (println (str "Param '" speaker "'"))
>                 )
>
> Here is the test using the mock request:
>
> (let [req (request :get "/api/outlines" {:speaker "Test Speaker 1"})]
>         (is (= expected-outlines (api-routes req))))
>
> Here is the value of the request and the 'speaker' parameter in the
> handler:
>
> Request {:remote-addr "localhost", :scheme :http, :context "/api",
> :request-method :get, :query-string "speaker=Test+Speaker+1", :route-params
> {}, :path-info "/outlines", :uri "/api/outlines", :server-name "localhost",
> :params {}, :headers {"host" "localhost"}, :server-port 80}
> Param ''
>
> The mock library apparently puts the GET params into query-string, so
> Compojure does not see them.  Is there a way to work around this without
> changing ring.mock.request?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to