This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-12
Channels
- # adventofcode (2)
- # aleph (2)
- # announcements (5)
- # aws (5)
- # babashka (25)
- # beginners (167)
- # calva (8)
- # cider (1)
- # clj-kondo (3)
- # cljsrn (19)
- # clojure (87)
- # clojure-conj (7)
- # clojure-dev (19)
- # clojure-europe (1)
- # clojure-italy (14)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-spec (18)
- # clojure-uk (29)
- # clojuredesign-podcast (3)
- # clojurescript (40)
- # clojurex (11)
- # core-async (13)
- # core-logic (2)
- # cursive (16)
- # data-science (4)
- # datascript (10)
- # datomic (53)
- # emacs (1)
- # events (15)
- # fulcro (71)
- # jobs (1)
- # jvm (2)
- # malli (4)
- # nrepl (2)
- # pathom (74)
- # re-frame (1)
- # reitit (19)
- # remote-jobs (1)
- # rewrite-clj (18)
- # ring (2)
- # shadow-cljs (132)
- # spacemacs (22)
- # tools-deps (65)
{:not-found
(constantly (response/ok (io/input-stream
(io/resource "public/index.html"))))
could not figure out the pattern yet as to why sometimes it throws the above warning and does noting
Here’s an example that serves the index.html
with ring.util.response/resource-response
https://github.com/metosin/reitit/blob/master/examples/frontend/src/backend/server.clj
I suspect you are getting IOException
because you open the stream only once and try to serve it more than once
@jstuartmilne constantly
calls the body once and returns always the same response. Second time you call the same endpoint, the Stream is already closed. Instead, you should re-create the stream for all request: (fn [_] (response/ok (io/input-stream (io/resource "public/index.html"))))
The example at Clojuredocs shows how constantly works in this case. https://clojuredocs.org/clojure.core/constantly
(map (constantly (rand-int 100)) [:a :b :c])
user=> (43 43 43)
The (rand-int 100)
is evaluated only once.