mirror of
https://github.com/metosin/reitit.git
synced 2025-12-24 19:08:24 +00:00
Downcase hidden methods in RESTful example
- this documentation is mildly confusing when combined with hiccup's
`form-to` since hiccup forcibly transforms the method specified in
its convenience syntax: `(form-to [:delete "/my-url"] ... )` into an
upper-case string:
80e48352dd/src/hiccup/form.clj (L130)
- it's also common to get an upper-case string from elsewhere so it
seems best to wrap the hidden `_method` in `lower-case`.
This commit is contained in:
parent
3a6985eb71
commit
a3b251449b
1 changed files with 4 additions and 3 deletions
|
|
@ -8,9 +8,10 @@ We can do this with middleware in reitit like this:
|
|||
```clj
|
||||
(defn- hidden-method
|
||||
[request]
|
||||
(keyword
|
||||
(or (get-in request [:form-params "_method"]) ;; look for "_method" field in :form-params
|
||||
(get-in request [:multipart-params "_method"])))) ;; or in :multipart-params
|
||||
(keyword
|
||||
(clojure.string/lower-case
|
||||
(or (get-in request [:form-params "_method"]) ;; look for "_method" field in :form-params
|
||||
(get-in request [:multipart-params "_method"]))))) ;; or in :multipart-params
|
||||
|
||||
(def wrap-hidden-method
|
||||
{:name ::wrap-hidden-method
|
||||
|
|
|
|||
Loading…
Reference in a new issue