Here's my handler setup:
(def app
(routes
(-> (handler/api api-routes)
(wrap-params)
(wrap-restful-format)
(wrap-reload))
(-> (handler/site www-routes)
(wrap-resource "public")
(wrap-content-type)
(wrap-reload))))
On Saturday, July 12, 2014 7:42:53 PM UTC-4, Jonathon McKitrick wrote:
>
> Hmm, except I don't have any issues when accessing it via an http client.
> Only with the mock.
>
> On Saturday, July 12, 2014 6:24:28 PM UTC-4, James Reeves wrote:
>>
>> 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 <[email protected]> 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 [email protected]
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> 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 [email protected].
>>> 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.