I'm trying to serve a file using ring-middlewares/fast-resource. It works, but the response has content type octet-stream. When I try to modify that to be text/html using an interceptor, the interceptor doesn't seem to fire. But if I put that interceptor before a different handler it works as expected. What should I be doing differently? https://paste.sr.ht/~eskin/a4c6148fe5137f61c7678b67b9d9dd55fba1549d
Maybe the file whose content-type is stubborn is being served by default-interceptors, given :http/resource-path, and not by the interceptor you had intended for the purpose. That interceptor is probably missing all targets because fast-resource finds resources on the classpath, composing a classpath-relative location from the root path and the request, but in the given interceptor the root path is given as an absolute filename, so fast-resource is probably not finding anything. One other minor thing - note that the fast-resource may also set Content-Length and Last-Modified headers, but the interceptor would obliterate them when adding Content-Type. An idiom that can be helpful in this situation of nested maps is (assoc-in context [:response :headers "Content-Type"] ...)
Thank you!! Switching to relative paths (I wasn't sure where exactly it was relative from before, but figured out it was "resources"), and blowing away :http/resource-path fixed it for me!
I think this underscores the need for a smarter, standard, default router that can work efficiently and support wild-cards, so that you introduce this kind of behavior as a route not an interceptor.