This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-16
Channels
- # announcements (2)
- # asami (5)
- # babashka (52)
- # beginners (42)
- # biff (3)
- # cljdoc (4)
- # cljsrn (2)
- # clojure (30)
- # clojure-austin (35)
- # clojure-dev (3)
- # clojure-france (11)
- # clojurescript (36)
- # conjure (6)
- # cursive (5)
- # fulcro (33)
- # graalvm (41)
- # lsp (54)
- # malli (1)
- # music (2)
- # off-topic (7)
- # overtone (1)
- # pedestal (5)
- # polylith (2)
- # remote-jobs (1)
- # sci (28)
- # shadow-cljs (38)
- # vim (15)
- # web-security (1)
- # xtdb (8)
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)"
[handler]
(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
(ajax-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
:io.pedestal.http.jetty/http-configuration
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 assoc
es :request-method
. Possibly just that?
👍 1