Clojure环回卷无法正常工作 [英] Clojure Ring wrap-reload is not working

查看:40
本文介绍了Clojure环回卷无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的core.clj文件

This is my core.clj file

(ns lein-app.core
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [ring.middleware.reload :refer [wrap-reload]]))

(use 'ring.adapter.jetty)

(defroutes app
  (GET "/" [] "<h1>Hello world</h1>")
  (route/not-found "<h1>Not found</h1>"))

(def reloadable-app
  (wrap-reload app))

(defn -main
  []
  (run-jetty reloadable-app {:port 3000}))

这是我的专案.clj

(defproject lein-app "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [
    [org.clojure/clojure "1.8.0"]
    [compojure "1.5.2"]
    [ring "1.5.0"]]

  :main lein-app.core)

当我运行lein run时,它将正确启动服务器,但是例如,如果我将GET响应更改为其他任何内容,则需要终止服务器并重新启动它.

When I run lein run it starts the server correctly but if I change the GET response to be anything else for example I need to kill the server and restart it.

推荐答案

如环对于 wrap-reload (以及其他库/项目中的类似功能),必须传递var本身而不是值.

For wrap-reload (as well for similar functionality in other libs/projects) one has to pass the var itself not the value.

像这样

(wrap-reload #'app)

这篇关于Clojure环回卷无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆