I have a web application templated with Chestnut, which uses danielsz’s system library, built on top of stuartsierra’s components library, for its set of
handler components. (I templated with bidi, which I don’t think matters.)
Out of the box, doing a
GET / resolves into the template’s
home-routes entry just fine, i.e.
index.html is served as expected.
I’m trying to add an API path prefix with some extra Ring middleware not on the main site. Just JSON handling and form multipart params. However, now
GET / raises
Key must be integer from
APersistentVector, which tells me that the either the routing table is mapping to a different handler function that is returning a vector (impossible), or the way I have the Ring middleware set up is mangling something in that call stack (likely).
I’m adding a second
endpoint with Ring middleware custom to it, with routes all under the
"/api/" path prefix. I take the API routes wrapped as a function that takes the system named as
endpoint as a positional argument. I take that and pass it to
new-endpoint. I then take that and make it depend at runtime to a
middleware object (composed as
new-middleware and a vector of the extra Ring middleware
wrap- functions to add). I then take the original
endpoint (which I didn’t touch), the new API
endpoint which had the API-specific middleware injected, and the original
middleware (that had the base middleware for the whole site), combined as three dependencies to inject into the result of
new-handler. I make sure that the site-wide
middleware is under the
:middleware key as stated in danielsz’s docs.
I think I did it all right? But maybe not? I just don’t have any handler functions that return vectors, so it must be the middleware call stack, right?