ring-clojure / ring-clojure/ring
documentation for using wrap-reload
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 3.9k
- Forks
- 528
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/ring-clojure/ring/blob/master/ring-devel/src/ring/middleware/reload.clj
It appears wrap-reload needs to be passed a handler as normal, but with the caveat that its referenced through a var (see https://github.com/mmcgrana/ring/issues/72).
Something along the lines of:
(def app
(-> (compojure.core/routes my-routes)
(compojure.handler/api)))
(def app-with-reload
(ring.middleware.reload/wrap-reload #'app))
(defn -main []
(ring.adapter.jetty/run-jetty #'app-with-reload {:port 8081 :join? false})
(ring.adapter.jetty/run-jetty #'app-with-reload {:port 8082 :join? false}))
If instead wrap-reload is treated as a normal middleware—placed in the chain for app—it seems to work but the updated behavior is actually delayed by one request.
Raising this issue to hopefully get some documentation in wrap-reload that makes note that it needs the var reference; also it may be helpful for it to throw an exception if it's not passed a var to prevent accidental use as typical middleware.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ring-devel/src/ring/middleware/reload.clj and the wrap-reload entry point. Document that the handler is passed through a var reference, include the example usage from the issue, and explain the delayed behavior when it is used as ordinary middleware; clarify whether the proposed invalid-argument exception is part of the documentation scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100