I use a secretary and a reagent. This is my code:
(def view (atom nil)) (defn layout [view] [:div @view]) (reagent/render-component [layout view] (.getElementById js/document "message")) (secretary/set-config! :prefix "") (secretary/defroute home-path "/" [query-params] (timbre/info "Path : /, query params : " query-params) (let [warning (:warning query-params) success (:success query-params) login-failed (:login_failed query-params)] (when warning (timbre/info "Warning found : " warning) (reset! view [:h4 [:span.label.label-warning warning]])) (when success (timbre/info "Success found : " success) (reset! view [:h4 [:span.label.label-info success]])) (when login-failed (timbre/info "Login failed") (reset! view [:h4 [:span.label.label-warning "Login Failed."]])))) (let [h (History.)] (goog.events/listen h EventType.NAVIGATE
Excluding the prefix value (I tried "," # ", and also did not set the prefix: this code only works with routes such as:
http://localhost:8080/login
But it does not work with such routes as:
http:
What I'm actually trying to achieve is to analyze the login failure from friend , which in case of failure redirects me to
http:
and display a login error message to the user. I do not need to use a secretary for this , everything that works to analyze the request parameters would be ok for me.
The hard way would be to parse the query string with which I can get:
(-> js/window .-location .-search)
I believe this is already well done in some library.
clojurescript reagent secretary
Viktor K.
source share