This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-03
Channels
- # aws (5)
- # beginners (67)
- # boot (30)
- # cider (55)
- # clara (7)
- # cljs-dev (6)
- # cljsjs (6)
- # cljsrn (1)
- # clojure (136)
- # clojure-brasil (2)
- # clojure-dusseldorf (14)
- # clojure-finland (9)
- # clojure-italy (49)
- # clojure-nl (1)
- # clojure-romania (6)
- # clojure-russia (4)
- # clojure-uk (16)
- # clojurescript (136)
- # core-async (1)
- # cursive (21)
- # datomic (64)
- # fulcro (26)
- # hoplon (25)
- # jobs-discuss (53)
- # keechma (3)
- # leiningen (6)
- # luminus (11)
- # lumo (2)
- # off-topic (351)
- # om (1)
- # onyx (11)
- # parinfer (32)
- # portkey (9)
- # re-frame (45)
- # reagent (38)
- # shadow-cljs (60)
- # specter (9)
- # vim (8)
- # yada (22)
Hello, I'm having a hard time configuring yada to serve static files out of the /public
directory, but relative to the server route. For example, I'd like to serve public/js/app.js
at the route /js/app.js
, so stripping public
completely. My bidi routes look as follows:
["/" [#{"js" "css"} {true (yada/resource
(cp/new-classpath-resource "public"))}]]
The route is matched and the handler is called but rather than returning my file it responds with a 405.That 'true' looks wrong to me
Am I right in thinking yada performs additional matching on top of the bidi routes passed in to yada/listener
?
No, it doesn't do any additional matching
Ah, I see what you mean.
Yes, a bidi 'matched' (such as a yada resource) can decide to match on a route even if there is a 'remaining' path yet to consume. In this case, this remaining path is called the 'path-info'.
classpath-resource makes use of this trick, so does the file/dir resources
try having a look at edge and compare how it serves up static resources compared to your code
usually it's just something simple
{true ...}
looks wrong to me
I'm not sure what you're doing there
what do you mean by the #{"js" "css"}
?
Yeah, that was bit of a fudge to get match-route
to work, but now I see there's more going under the hood.
I mean, that's OK as a pattern
A bidi route is simply [pattern matched]
, where matched is a handler or vector of nested bidi routes
I want the routes to match files being served out of the public directory inside js
and css
subdirs.
Try with 2 routes (`/js` and /css
) and get that working first
but yes, you should be able to match on a set
[["/" #{"js" "css"}] (cp/new-classpath-resource ....)]