forked from ring-clojure/ring
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed wrap-reload to automatically reload modified source files
- Loading branch information
1 parent
9841dfd
commit f39e24d
Showing
3 changed files
with
21 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,14 +1,18 @@ | |||
(ns ring.middleware.reload | (ns ring.middleware.reload | ||
"Reload namespaces before requests.") | "Reload modified namespaces on the fly." | ||
(:use [ns-tracker.core :only (ns-tracker)])) | |||
|
|
||
(defn wrap-reload | (defn wrap-reload | ||
"Wrap an app such that before a request is passed to the app, each namespace | "Reload namespaces of modified files before the request is passed to the | ||
identified by syms in reloadables is reloaded. | supplied handler. | ||
Currently this requires that the namespaces in question are being (re)loaded | |||
from un-jarred source files, as apposed to source files in jars or compiled | Takes the following options: | ||
classes." | :dirs - A list of directories that contain the source files. | ||
[app reloadables] | Defaults to [\"src\"]." | ||
(fn [req] | [handler & [options]] | ||
(doseq [ns-sym reloadables] | (let [source-dirs (:dirs options ["src"]) | ||
(require ns-sym :reload)) | modified-namespaces (ns-tracker source-dirs)] | ||
(app req))) | (fn [request] | ||
(doseq [ns-sym (modified-namespaces)] | |||
(require ns-sym :reload)) | |||
(handler request)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters