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

I am creating a one-page application that routes all of its client-side html requests and uses the dropwizard on the backend to provide many JSON services.

Essentially, I can’t get the dock in dropwizard to maintain index.html for each request, except for the following paths: / CSS / i 18n / IMG / JS / Lib / Services / Templates

In fact, I have a lot of problems finding documentation that tells how to configure any http routing in general. (I am not a guy from java).

Here is my simple yaml configuration: http: port: 8082 adminPort: 8083 rootPath: /service/*

What I need to add for this.

thanks

+8
java jetty configuration dropwizard
source share
1 answer

I did this without changing my configuration. In fact, I needed only one line of code that should be placed in the initialize method of my Application class:

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

It basically says that in my JAR file under the URL pattern / , <under /app , and index.html is the default file. This package will be called static, but you can choose any name you like.

Please note that I am using version 0.7.0-rc2 Dropwizard, I am not sure if it works for earlier versions either.

+14
source share

All Articles