Permalink
Browse files

allow path for admin servlet to be configured in AdminServletModule, …

…ensure listens to /* not just / and update test so that it passes
  • Loading branch information...
1 parent c84b0be commit bb34576fd74e39b49732c71c878dc26fa15ad8f3 @davemssavage committed Jun 9, 2012
@@ -48,32 +48,41 @@
* </pre>
*/
public class AdminServletModule extends ServletModule {
+
+ public static final String DEFAULT_PATH = "/metrics";
+
private final JsonFactory jsonFactory;
private final String healthcheckUri;
private final String metricsUri;
private final String pingUri;
private final String threadsUri;
+ private final String path;
- public AdminServletModule() {
- this(null, AdminServlet.DEFAULT_HEALTHCHECK_URI, AdminServlet.DEFAULT_METRICS_URI,
+ public AdminServletModule() {
+ this(null, DEFAULT_PATH, AdminServlet.DEFAULT_HEALTHCHECK_URI, AdminServlet.DEFAULT_METRICS_URI,
AdminServlet.DEFAULT_PING_URI, AdminServlet.DEFAULT_THREADS_URI);
}
public AdminServletModule(JsonFactory jsonFactory) {
- this(jsonFactory, AdminServlet.DEFAULT_HEALTHCHECK_URI, AdminServlet.DEFAULT_METRICS_URI,
+ this(jsonFactory, DEFAULT_PATH, AdminServlet.DEFAULT_HEALTHCHECK_URI, AdminServlet.DEFAULT_METRICS_URI,
AdminServlet.DEFAULT_PING_URI, AdminServlet.DEFAULT_THREADS_URI);
}
public AdminServletModule(String healthcheckUri, String metricsUri, String pingUri, String threadsUri) {
- this(null, healthcheckUri, metricsUri, pingUri, threadsUri);
+ this(null, DEFAULT_PATH, healthcheckUri, metricsUri, pingUri, threadsUri);
}
public AdminServletModule(JsonFactory jsonFactory, String healthcheckUri, String metricsUri, String pingUri, String threadsUri) {
+ this(jsonFactory, DEFAULT_PATH, healthcheckUri, metricsUri, pingUri, threadsUri);
+ }
+
+ public AdminServletModule(JsonFactory jsonFactory, String path, String healthcheckUri, String metricsUri, String pingUri, String threadsUri) {
this.jsonFactory = jsonFactory;
this.healthcheckUri = healthcheckUri;
this.metricsUri = metricsUri;
this.pingUri = pingUri;
this.threadsUri = threadsUri;
+ this.path = path;
}
@Override
@@ -87,6 +96,6 @@ protected void configureServlets() {
bind(String.class).annotatedWith(Names.named("AdminServlet.THREADS_URI")).toInstance(threadsUri);
bind(AdminServlet.class).toProvider(AdminServletProvider.class).asEagerSingleton();
- serve(healthcheckUri, metricsUri, pingUri, threadsUri).with(AdminServlet.class);
+ serve(path + "/*").with(AdminServlet.class);
}
}
@@ -46,7 +46,7 @@ public void tearDown() throws Exception {
@Test
public void shouldProvideValidJsonForMetrics() throws Exception {
- final String url = "http://127.0.0.1:" + localPort + AdminServlet.DEFAULT_METRICS_URI;
+ final String url = "http://127.0.0.1:" + localPort + AdminServletModule.DEFAULT_PATH + AdminServlet.DEFAULT_METRICS_URI;
final AsyncHttpClient client = new AsyncHttpClient();
final Response response = client.prepareGet(url).execute().get();

0 comments on commit bb34576

Please sign in to comment.