-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
20095c5
commit dc1c4eb
Showing
9 changed files
with
172 additions
and
46 deletions.
There are no files selected for viewing
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
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
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
32 changes: 21 additions & 11 deletions
32
ehealthid-rp/src/main/java/com/oviva/ehealthid/relyingparty/ws/HealthEndpoint.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
package com.oviva.ehealthid.relyingparty.ws; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
import io.undertow.server.HttpHandler; | ||
import io.undertow.server.HttpServerExchange; | ||
import io.undertow.util.Headers; | ||
import io.undertow.util.HttpString; | ||
|
||
@Path("/health") | ||
public class HealthEndpoint { | ||
public class HealthEndpoint implements HttpHandler { | ||
public static final String PATH = "/health"; | ||
|
||
private static final int HTTP_METHOD_NOT_ALLOWED = 405; | ||
private static final int HTTP_OK = 200; | ||
|
||
private static final String STATUS_UP = "{\"status\":\"UP\"}"; | ||
|
||
@GET | ||
public Response get() { | ||
// For now if this endpoint is reachable then the service is up. There is no hard dependency | ||
// that could be down. | ||
return Response.ok(STATUS_UP).type(MediaType.APPLICATION_JSON_TYPE).build(); | ||
@Override | ||
public void handleRequest(HttpServerExchange httpServerExchange) { | ||
if (!httpServerExchange.getRequestMethod().equals(HttpString.tryFromString("GET"))) { | ||
httpServerExchange.setStatusCode(HTTP_METHOD_NOT_ALLOWED); | ||
httpServerExchange.getResponseSender().send(""); | ||
} else { | ||
// For now if this endpoint is reachable then the service is up. | ||
// There is no hard dependency that could be down. | ||
httpServerExchange.setStatusCode(HTTP_OK); | ||
httpServerExchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json"); | ||
httpServerExchange.getResponseSender().send(STATUS_UP); | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.