Skip to content

Commit

Permalink
Read query string in HTML5 router
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraen committed Aug 23, 2018
1 parent 0bd1b94 commit e42c309
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/frontend/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@

:figwheel {:http-server-root "public"
:server-port 3449
:nrepl-port 7002})
:nrepl-port 7002
:ring-handler backend.server/handler})
2 changes: 1 addition & 1 deletion examples/frontend/resources/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
</head>
<body>
<div id="app"></div>
<script src="js/app.js"></script>
<script src="/js/app.js"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions examples/frontend/src/backend/server.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(ns backend.server
(:require [clojure.java.io :as io]
[ring.util.response :as resp]
[ring.middleware.content-type :as content-type]))

(def handler
(-> (fn [request]
(or (resp/resource-response (:uri request) {:root "public"})
(-> (resp/resource-response "index.html" {:root "public"})
(resp/content-type "text/html"))))
content-type/wrap-content-type))
3 changes: 2 additions & 1 deletion modules/reitit-frontend/src/reitit/frontend/history.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
(gevents/unlistenByKey listen-key)
(gevents/unlistenByKey click-listen-key))
(-get-path [this]
(.. js/window -location -pathname))
(str (.. js/window -location -pathname)
(.. js/window -location -search)))
(-href [this path]
path))

Expand Down

0 comments on commit e42c309

Please sign in to comment.