Skip to content

Instantly share code, notes, and snippets.

@ksahnine
Created January 15, 2015 09:45
Show Gist options
  • Save ksahnine/b36f6a56c78f162d0113 to your computer and use it in GitHub Desktop.
Save ksahnine/b36f6a56c78f162d0113 to your computer and use it in GitHub Desktop.
Dropwizard - Health check
public class RatpHealthCheck extends HealthCheck {
private String urlRatp;
public RatpHealthCheck(String urlRatp) {
this.urlRatp = urlRatp;
}
@Override
protected Result check() throws Exception {
URL url = new URL(urlRatp);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
final int status = connection.getResponseCode();
if (status != 200 ) {
return Result.unhealthy("Indisponibilité du site RATP");
}
return Result.healthy();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment