I have another really basic question about yada and bidi, but I couldn't find it anywhere. Bidi allow to assign identifiers to URIs, which is great, so I have created routes data like this:
(def routes
["" [["" :page/index]
["/css/" :resource/css]
["/js/" :resource/js]
[true :routes/no-match]]])
Next, I have created a map from these identifiers to yada resources:
{:page/index (y/as-resource (io/resource "public/index.html"))
:resource/css (y.resources-resource/new-resources-resource "public/css/")
:resource/js (y.resources-resource/new-resources-resource "public/js/")
:routes/no-match (y/as-resource nil)}
But what is the idiomatic way to join these together to create a single yada handler? Currently I am using this, not sure how to change it:
(y/listener
[""
[["" (y/as-resource (io/resource "public/index.html"))]
["/css/" (y.resources-resource/new-resources-resource "public/js/")]
["/js/" (y.resources-resource/new-resources-resource "public/js/")]
[true (y/as-resource nil)]]]
{:port port})
This is correct. You can associate each yada resource with an id. This is done via the :id key, which you can specify in custom resources and assoc into builtin resources. Then yada/path-for and yada/url-for will work.