我正在構建由兩個Clojure項目組成的Compojure webapp。第一個是用於可視化一些數據的web應用程序,第二個是需要使用第一個應用程序的更復雜的應用程序。在Compojure中設置路由的上下文路徑
我希望能夠在第二個項目中同時運行兩個應用程序run-jetty。這將允許第二個Web應用程序調用第一個Web應用程序的URL來獲取可視化。
我使用背景從宏觀的Compojure,這裏是第二個應用程序的路徑:
(def second-project-main-routes
[
(context "/second" request
(GET "/viewsession" {session :session} (str session))
(GET "/resetsession" [] (reset-session))
... other routes here ...
(route/resources "/"))
])
(def second-all-routes
(concat second-project-main-routes
first-project-routes)
(def second-app
(-> (handler/site (apply routes second-all-routes))
(wrap-base-url)))
;; to comment when building the JAR:
(defonce second-server (run-jetty #'second-app {:join? false :port 8080}))
和這裏的第一個應用程序的路徑:
(def first-project-routes
[(context "/first" request
(GET "/" [] (index-page))
(route/files "/" {:root (str (System/getProperty "user.dir") "/data/public")})
(route/resources "/"))])
我有兩個main.js文件。一個在firstproject /資源/公/ JS /應用/ main.js和secondproject一個 /資源/公/ JS /應用/ main.js
當我瀏覽網址本地主機:8080/first/app/js/main.js我得到第二個項目的main.js。爲什麼?