yada

2018-04-03T15:24:58.000043Z

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.

malcolmsparks 2018-04-03T15:34:24.000085Z

That 'true' looks wrong to me

2018-04-03T15:34:43.000097Z

Am I right in thinking yada performs additional matching on top of the bidi routes passed in to yada/listener?

2018-04-03T15:35:29.000300Z

Specifically for sub-resources.

malcolmsparks 2018-04-03T15:35:43.000415Z

No, it doesn't do any additional matching

malcolmsparks 2018-04-03T15:37:14.000190Z

Ah, I see what you mean.

malcolmsparks 2018-04-03T15:37:52.000169Z

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'.

malcolmsparks 2018-04-03T15:38:07.000715Z

classpath-resource makes use of this trick, so does the file/dir resources

malcolmsparks 2018-04-03T15:38:31.000226Z

try having a look at edge and compare how it serves up static resources compared to your code

malcolmsparks 2018-04-03T15:38:40.000786Z

usually it's just something simple

2018-04-03T15:38:52.000703Z

Aha, OK that should set me on the right path.

malcolmsparks 2018-04-03T15:38:53.000226Z

{true ...} looks wrong to me

malcolmsparks 2018-04-03T15:39:07.000444Z

I'm not sure what you're doing there

malcolmsparks 2018-04-03T15:39:34.000414Z

what do you mean by the #{"js" "css"} ?

2018-04-03T15:39:47.000756Z

Yeah, that was bit of a fudge to get match-route to work, but now I see there's more going under the hood.

malcolmsparks 2018-04-03T15:39:59.000340Z

I mean, that's OK as a pattern

malcolmsparks 2018-04-03T15:40:26.000691Z

A bidi route is simply [pattern matched], where matched is a handler or vector of nested bidi routes

2018-04-03T15:40:35.000456Z

I want the routes to match files being served out of the public directory inside js and css subdirs.

malcolmsparks 2018-04-03T15:41:27.000479Z

Try with 2 routes (`/js` and /css) and get that working first

malcolmsparks 2018-04-03T15:41:35.000033Z

but yes, you should be able to match on a set

malcolmsparks 2018-04-03T15:41:58.000058Z

[["/" #{"js" "css"}] (cp/new-classpath-resource ....)]

2018-04-03T15:42:23.000209Z

Ah gotcha. Thanks, I'll take a look at edge and let you know what I find.