File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .io .IOException ;
2+ import java .net .URI ;
3+ import java .net .http .HttpClient ;
4+ import java .net .http .HttpRequest ;
5+ import java .net .http .HttpResponse .BodyHandlers ;
6+
7+ static void main (String [] args ) throws IOException , InterruptedException {
8+ final var client = HttpClient .newHttpClient ();
9+ final var request = HttpRequest .newBuilder ()
10+ .uri (URI .create ("http://localhost:8080/actuator/health" ))
11+ .header ("accept" , "application/json" )
12+ .build ();
13+
14+ final var response = client .send (request , BodyHandlers .ofString ());
15+ final var body = response .body ();
16+
17+ System .out .print ("Status: " + response .statusCode ());
18+ System .out .print (" | body: " + body );
19+ System .out .println ();
20+
21+ if (response .statusCode () != 200 || !body .contains ("UP" )) {
22+ System .err .println ("Service is not UP!" );
23+ System .exit (1 );
24+ } else {
25+ System .exit (0 );
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments