Skip to content

Commit

Permalink
fix complex pre-route url issue
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Granger <ibdknox@gmail.com>
  • Loading branch information
ibdknox committed Oct 7, 2011
1 parent 1b04e62 commit 3133daa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/noir/core.clj
Expand Up @@ -142,8 +142,11 @@
(pre-route '/admin/*' {} (when-not (is-admin?) (redirect '/login')))"
[& args]
(let [{:keys [action destruct url body]} (parse-args args)]
`(swap! pre-routes assoc ~url (~action ~url {:as request#} ((fn [~destruct] ~@body) request#)))))
(let [{:keys [action destruct url body]} (parse-args args)
safe-url (if (vector? url)
(first url)
url)]
`(swap! pre-routes assoc ~safe-url (~action ~url {:as request#} ((fn [~destruct] ~@body) request#)))))

(defmacro post-route
"Adds a route to the end of the route table and passes the entire request to
Expand Down

0 comments on commit 3133daa

Please sign in to comment.