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
?
Specifically for sub-resources.
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
Aha, OK that should set me on the right path.
{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 ....)]
Ah gotcha. Thanks, I'll take a look at edge and let you know what I find.