Changing the mime type of assets in Dropwizard

I’m serving static content with Dropwizard’s AssetsBundle(0.6.2), and a problem occured where .handlebars-files arrived as text/html-files.

This was a problem in our project, because we were behind a proxy that added certain script tags to all text/html-files, so we needed to find a way to make dropwizard give the handlebars-files out as text/plain.

After a lot of trying, I gave up, but my colleague came up with this ingenious solution:

  1. Copy mime.properties from org.eclipse.jetty.http to the same package in your own source, for example src\main\resources\org\eclipse\jetty\http\mime.properties

  2. Add handlebars=text/plain to your copy of the file

Dropwizard will now use your properties-file instead of the original one.

Share