作为学习Luminus的开始,我正在尝试创建一个简单的API来与本地服务器环境交互。写一个基本的文件看起来是一个很好的开始,但是我不能让它工作。从home.clj查看我的代码
(defroutes test-routes
(GET "/spit/:file-name/:file-text" [file-name file-text]
(spit file-name file-text)
{:status 200
:headers {"Content-Type" "text/html; charset=utf-8"}
:body (str "File name: " file-name "<br />File text: " file-text)}))Luminus只返回两个单词Not Found。
第二个例子也不起作用:
(defroutes test-routes
(GET "/spit" []
(spit "test.txt" "test")
{:status 200
:headers {"Content-Type" "text/html; charset=utf-8"}
:body (str "File name: " "<br />File text: " )}))发布于 2014-05-01 03:21:01
我刚想通了。问题是没有正确地将test-routes添加到handler.clj中。因此,我引用了home.clj中的符号test-routes,并将test-routes添加到app-handler调用中的路由符号矢量中。
我还发现ring服务器有时需要重新启动才能使更改显示在应用程序中。路由似乎也必须在app-routes之前列出。
https://stackoverflow.com/questions/23394703
复制相似问题