-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request with PATCH method do not include the body in the request structure. #12
Comments
@jsofra :/ Thanks for reporting, Could be a limitation of nanohttpd. Do you know or recommend a small simple http server that is still maintained? Maybe we can switch it instead. |
@johanhaleby thanks for the reply. I dug into nanohttpd and it does seem to be a limitation ... As far are small simple http servers I am not sure. I guess there is always Jetty, not that it is that small, or possibly http-kit. Anyway, it is a nice library, thanks :) |
I accidentally wrote "Maybe you can switch it instead" instead of "Maybe we can switch it instead". Sorry about that, it was not my intension :) Thanks for digging in to nanohttpd. Maybe switching to something more mainstream like jetty or undertow would make sense. Presumable we won't find limitations like this so it could be worth the extra library size. |
I ended up just going with this using jetty: (require '[ring.adapter.jetty :as jetty])
(require '[reitit.ring :as ring])
(require '[clj-http.client :as client])
(defn start-server [routes options]
(jetty/run-jetty (ring/ring-handler (ring/router routes)) (merge {:join? false} options)))
(defmacro with-server [options routes & body]
`(let [server# (start-server ~routes ~options)]
(try
~@body
(finally (.stop server#)))))
(with-server {:port 3000}
[["/my/route" (fn [_]
{:status 200
:body "hello"})]]
(client/get "http://localhost:3000/my/route" {})) Not very sophisticated but got the job done. |
Yes, works perfectly well :) Glad you found a workaround and thanks for
sharing.
…On Wed, Jul 15, 2020 at 3:09 PM James Sofra ***@***.***> wrote:
I ended up just going with this using jetty:
(require '[ring.adapter.jetty :as jetty])
(require '[reitit.ring :as ring])
(require '[clj-http.client :as client])
(defn start-server [routes options]
(jetty/run-jetty (ring/ring-handler (ring/router routes)) (merge {:join? false} options)))
(defmacro with-server [options routes & body]
`(let [server# (start-server ~routes ~options)]
(try
***@***.***
(finally (.stop server#)))))
(with-server {:port 3000}
[["/my/route" (fn [_]
{:status 200
:body "hello"})]]
(client/get "http://localhost:3000/my/route" {}))
Not very sophisticated but got the job done.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABNVFM64MQJPYQTCM6NK43R3WTBVANCNFSM4O2C5WDQ>
.
|
When stubbing a PATCH method request the stub-request returned from the nano server has no body.
This means tests that rely on the body for generating a response for PATCH request cannot be written.
e.g.
The text was updated successfully, but these errors were encountered: