Using duct.module.web/site, is there a way to have my own custom 404 handler?
Yes, you can override :duct.middleware.web/not-found, e.g.
:duct.middleware.web/not-found
{:error-handler #ig/ref :example.handler/not-found}
:example.handler/not-found {}If you want a static 404 handler, you could also instead override the default 404 handler and change the body to a resource of your choice:
:duct.handler.static/not-found
{:body #duct/resource "public/404.html"}Thx @weavejester I found the later one in your blog post from 2017. 🙂 But in this case I think I need the first approach. (I'm trying to integrate hanami into a duct app, and I want to proxy the requests for hanami's assets to its own http server.) But as always you have a nifty solution for it. Reading your code I always find myself in between awe and "where is stuff actually happening?" 🙏
I'm hoping that the next version of Duct will help with the latter. My intent is to make modules conceptually simpler, and to write a tool to display all the expanded keys along with which module is responsible for them.
In the meantime, it can be useful to peek at the configuration in the REPL. I believe config will show you the configuration after the modules have been applied.
I was acutally poking around in config on the REPL yesterday, looking into another issue. I'm using reitit an another app set up very similar to this https://github.com/yannvanhalewyn/duct-reitit/blob/master/src/duct/router/reitit.clj and I have an odd issue with references to malli schemas. If introduced via CIDER in a running REPL these references seem fine and all is working as expected. But if I restart the REPL I get errors. But I have yet to figure out if this is a a question for #duct or rather metosin -- and what exactly my question is. 🙂 (So I don't expect to get an answer for this one!)
But I wondered if the approach to resolve symbols in the duct config like it is done here https://github.com/yannvanhalewyn/duct-reitit/blob/master/src/duct/router/reitit.clj#L20-L27 is sound?