Closed nackjicholson closed 1 month ago
You shouldn't need to use utils/route-data
since opts
from Integrant get passed to api-routes
and then can be passed directly to the controller, which is the first parameter in the example above. You can see the full example project here https://github.com/kit-clj/kit-examples/tree/master/guestbook
I appreciate the response @yogthos, this is helpful to see the guestbook code. The below line does use utils/route-data
though.
The example is a bit out of date, but if you look in the way the latest template is set up here https://github.com/kit-clj/kit/blob/master/libs/deps-template/resources/io/github/kit_clj/kit/src/clj/web/routes/api.clj#L35
The _opts
from Integrant are being passed in to the function that generates the API routes, so they can be directly passed to the controller function from there.
@yogthos Do I need to partial
the opts into the controler fn's from there? If so, then I think I have what I need to keep going. But, to the question of the PR, I think this does mean the documentation is quite out of date and inaccurate. It's even more out of date than the example app code.
Yup, using (partial your-handler opts)
will work here. I'll take a look at updating the relevant docs to match the latest before closing the issue.
The code mentioned in the getting started documentation here, does not work for me.
The request object is not possible to destructure in this way, for me. I also notice that the
utils
are imported but not used. I think the solution is that in kit, to access things injected by integrant you actually have to do something like(let [{:keys [query-fn]} (utils/route-data request)] ...)
. Is that correct? It would be super convenient to destructure it from the request as seen in the docs, for the record. I'm unfortunately struggling to get started with kit because I can't follow the documentation.