User Tools

Site Tools


dropwizard

This is an old revision of the document!


Dropwizard

Metrics

The Metrics library is used to get an insight view into the running server.

Adding additional metrics

To add additional metrics a MetricRegistry is needed. It can be obtained during the bootstrap phase.

@Override
public void initialize(Bootstrap<PostalCodeConfiguration> bootstrap) {
    metricRegistry = bootstrap.getMetricRegistry();
}

Jetty

Adding additional HTML pages

If you want to add additional HTML pages (like a welcome page) then you can do this in the initialize method of the Application class.

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

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.

dropwizard.1405676645.txt.gz · Last modified: 2014/07/18 09:44 by mihael