Fork me on GitHub

I would like to use “X-HTTP-Method-Override” in Pedestal. I see that is needed an extra setup. I found one at RING case

(defn wrap-method-override
  "Ring middleware for method overriding (X-HTTP-Method-Override)"
  (fn [req]
    (let [x-http-method (get (-> req :headers) "x-http-method-override" "")]
      (if (contains? #{"delete" "put"} (string/lower-case x-http-method))
        (handler (if x-http-method (assoc req :request-method (keyword (string/lower-case x-http-method))) req))
        (handler req)))))
[from ithaka]. Example request
  {:uri             "/api/post-get" ;; both exist here, get and post
   :method          :post
   :headers         {"X-HTTP-Method-Override" "GET"}
   :params          {:q  "something here"}
   :handler         (fn [data]
                      (js/console.log "success2 " data))
   :error-handler   (fn [data]
                      (js/console.log "error " data))
   :format          (ajax.json/json-request-format)
   :response-format (ajax.json/json-response-format)})
when I call, I see in the logs POST request, which is normally np.. because I can send back data in this way. Just I really want to understand why I can’t mod the method. I use Jetty + Pedestal. Any idea, maybe I need to write an interceptor or I need to add at Jetty side something (like Ring)? Maybe at
side (container options)?


Ofc, I can route POST to GET on server side, just my question is, is that possible in real change/ mod the method or not.


@U2T2ZEVPC I’m not deeply knowledgeable here, but the original request map uses :method whereas the middleware assoces :request-method. Possibly just that?

👍 1

Thanks I check it!


Ps. I tested with js/fetch too, same result.