Created
January 15, 2015 09:45
-
-
Save ksahnine/b36f6a56c78f162d0113 to your computer and use it in GitHub Desktop.
Dropwizard - Health check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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