Configure dropwizard to server index.html for (almost) all routes?

I’m building a single page application which does all of it’s html request routing on the client side and on the backend it uses dropwizard to provide a bunch of JSON services.

Essentially I’m having trouble getting the jetty in dropwizard to serve index.html for every request except to the following paths:


In fact I’m having a lot of trouble finding documentation that tells you how to setup any http routing at all. (I’m not a java guy).

Here’s my simple yaml config:`

  port: 8082
  adminPort: 8083
  rootPath: /service/*`

What do I need to add to acheive this.



I’ve done this without changing my configuration. In fact, it only took me one line of code, to be put in the initialize method of my Application class:

bootstrap.addBundle(new AssetsBundle("/app", "/", "index.html", "static"));

Which basically says to serve anything under /app inside my JAR file under the URL pattern /, with index.html as the default file. This bundle will be named static, but you could pick whatever name you like.

Note that I’m using version 0.7.0-rc2 of Dropwizard, I’m not sure whether it works for earlier versions as well.

Leave a Reply

Your email address will not be published. Required fields are marked *