kopia lustrzana https://github.com/gaul/s3proxy
Add `/healthz` endpoint for basic health check in S3Proxy
- Implemented a new `/healthz` endpoint to handle GET requests. - Added the `handleVersionRequest` method to return a JSON response with health status: - Response: `{ "status": "OK" }` - Updated `S3ProxyHandler` to route requests to `/healthz` and handle responses effectively. - The endpoint provides a simple mechanism for health monitoring and status validation.pull/763/head
rodzic
b8bd258dcd
commit
e0a1cf7657
|
@ -293,6 +293,12 @@ public class S3ProxyHandler {
|
|||
String uri = request.getRequestURI();
|
||||
String originalUri = request.getRequestURI();
|
||||
|
||||
// Check for the /version endpoint
|
||||
if ("/healthz".equals(uri) && "GET".equalsIgnoreCase(method)) {
|
||||
handleVersionRequest(response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.servicePath.isEmpty()) {
|
||||
if (uri.length() > this.servicePath.length()) {
|
||||
uri = uri.substring(this.servicePath.length());
|
||||
|
@ -2029,6 +2035,18 @@ public class S3ProxyHandler {
|
|||
|
||||
response.addHeader(HttpHeaders.ETAG, maybeQuoteETag(eTag));
|
||||
}
|
||||
private void handleVersionRequest(HttpServletResponse response) throws IOException {
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
String versionInfo = "{ \"status\": \"OK\"}";
|
||||
|
||||
try (PrintWriter writer = response.getWriter()) {
|
||||
writer.write(versionInfo);
|
||||
writer.flush();
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePostBlob(HttpServletRequest request,
|
||||
HttpServletResponse response, InputStream is, BlobStore blobStore,
|
||||
|
|
Ładowanie…
Reference in New Issue