This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-29
Channels
- # announcements (8)
- # aws (34)
- # beginners (92)
- # calva (19)
- # capetown (1)
- # cider (10)
- # cljs-dev (7)
- # cljsrn (11)
- # clojars (7)
- # clojure (130)
- # clojure-europe (4)
- # clojure-italy (4)
- # clojure-losangeles (1)
- # clojure-nl (11)
- # clojure-russia (1)
- # clojure-spec (4)
- # clojure-uk (64)
- # clojurescript (51)
- # cursive (9)
- # data-science (6)
- # datomic (29)
- # emacs (3)
- # figwheel-main (14)
- # fulcro (4)
- # graphql (3)
- # jackdaw (2)
- # jobs (4)
- # kaocha (17)
- # leiningen (3)
- # luminus (1)
- # off-topic (46)
- # pedestal (6)
- # portkey (2)
- # re-frame (6)
- # reagent (1)
- # reitit (9)
- # shadow-cljs (9)
- # sql (10)
- # yada (6)
Hi! I’m migrating from Compojure to Reitit, and looking for a way to make DELETE requests from HTML forms. In Compojure (as pioneered by Rails), you would add a hidden _method
field (`<input type="hidden" value="DELETE">`) that would make the DELETE
route handler to be invoked (see https://github.com/weavejester/compojure/blob/master/src/compojure/core.clj#L16). How do you make something like this happen in the Reitit world?
@msolli I would do that outside of router via middleware:
1) mount the parameters middleware (and optionally the multipart middleware) via :middleware
option in reitit.ring/ring-handler
=> needed to get access to :form-params
& :multipart-params
2) add a custom middleware that overwrites the :request-method
based on those, e.g. what compojure does
3) write a nice documentation page about this for future use
something like:
(reitit.ring/ring-handler
(reitit.ring/router ...)
(reitit.ring/create-default-handler)
{:middleware [reitit.ring.middleware.parameters/parameters-middleware
my-form-delete-change-request-method-middleware]})
Kool, I see. I’ll make it work, and I’ll try to document it for the benefit of others. Would you accept a PR for https://github.com/metosin/reitit/tree/master/doc, and if so, which section?