Fork me on GitHub
#ring
<
2021-06-05
>
km01:06:53

Hey guys, Anyone have an easy way to send multipart/form-data requests with ring-mock? I'm having a heck of a time trying to post a file.

Johnny15:06:33

My ring handler returns this response {:status 400, :headers {}, :body "Bad request."} (after middleware), however my browser receives a 404 with no body when I send a request. What might the reason for that be? I have no routing installed, and no part in my code creates a 404 response.

(defn wrap-log [handler]
  (fn [req]
    (println "-----REQUEST-----")
    (pprint req)
    (println "-----RESPONSE-----")
    (pprint (handler req))))

(def app
  (-> handler
      wrap-json-response
      wrap-clean-json
      wrap-json-body
      (wrap-authenticate (:public-key config))
      wrap-log))

(defn -main [& args]
  (mount/start)
  (http-server/run-server app))
This is an excerpt from my main namespace. I got the information about the response from the wrap-log middleware. The server is http-kit.

hiredman15:06:19

pprint is returning nil

hiredman15:06:44

wrap-log needs to actually return the result of the call to handler

Johnny15:06:05

Yep, I just found it too... Sometimes such obvious errors manage to escape your sight