【发布时间】:2015-02-05 05:35:29
【问题描述】:
我编写了一些 Clojurescript 代码,它们需要一个 REST 接口才能与服务器通信。后端目前使用 Python,我想将其移至 Clojure。现在我找到了 rook https://github.com/AvisoNovate/rook,它为我准备使用的 REST 提供了一个不错的 API。
但是我想使用 ring(由 rook 使用)在同一个 http 服务器上提供一些静态内容(基本上是 ClojureScript 的 html 和 JS)。
我的设置与现在 Rook 示例中的设置非常相似:
https://portal.aviso.io/#/document/open-source/rook/Current/example.html
(ns org.example.server (:进口 [org.eclipse.jetty.server 服务器]) (:要求 [ring.adapter.jetty:作为码头] [io.aviso.rook :as rook] [clojure.tools.logging :as l])) (定义启动服务器 “在指定端口上启动服务器,并返回一个将其关闭的函数。” [港口] (let [handler (-> (rook/namespace-handler) [“计数器”'org.example.resources.counters]) rook/wrap-with-standard-middleware) ^Server server (jetty/run-jetty handler {:port port :join?false})] (l/infof "监听端口 %d。" 端口) #(.stop 服务器))) (定义主要 [] (启动服务器 8080))我不清楚如何使用环静态资源功能运行它:https://github.com/ring-clojure/ring/wiki/Static-Resources
【问题讨论】: