Skip to content

Commit 4e5be1e

Browse files
committed
Modify status response format
1 parent b3c9ede commit 4e5be1e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

thumbly-main/src/main/java/org/code13k/thumbly/service/main/MainHttpServer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@ private void handler(RoutingContext routingContext,
252252

253253
// Check origin file
254254
if (StringUtils.isEmpty(cachedOriginFilePath) == true) {
255-
MainHttpServerHelper.sendStatus(routingContext, "NOT");
255+
MainHttpServerHelper.sendStatus(routingContext, false);
256256
return;
257257
}
258258

259259
// Get origin file
260260
if (command.getType() == Command.Type.ORIGIN) {
261-
MainHttpServerHelper.sendStatus(routingContext, "CACHED");
261+
MainHttpServerHelper.sendStatus(routingContext, true);
262262
return;
263263
}
264264

@@ -268,10 +268,10 @@ private void handler(RoutingContext routingContext,
268268
String cachedThumbFilePath = CachedImageProcessor.getInstance().getCachedFile(cachedOriginFilePath, command);
269269
mLogger.debug("cachedThumbFilePath = " + cachedThumbFilePath);
270270
if (StringUtils.isEmpty(cachedThumbFilePath) == true) {
271-
MainHttpServerHelper.sendStatus(routingContext, "NOT");
271+
MainHttpServerHelper.sendStatus(routingContext, false);
272272
return;
273273
} else {
274-
MainHttpServerHelper.sendStatus(routingContext, "CACHED");
274+
MainHttpServerHelper.sendStatus(routingContext, true);
275275
return;
276276
}
277277
}

thumbly-main/src/main/java/org/code13k/thumbly/service/main/MainHttpServerHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public static void sendResponse(RoutingContext routingContext, int statusCode, S
3535
/**
3636
* Send status
3737
*/
38-
public static void sendStatus(RoutingContext routingContext, String statusMessage) {
38+
public static void sendStatus(RoutingContext routingContext, boolean cached) {
3939
Map<String, Object> jsonResult = new HashMap<>();
40-
jsonResult.put("status", statusMessage);
40+
jsonResult.put("cached", cached);
4141
String result = new GsonBuilder().create().toJson(jsonResult);
4242

4343
HttpServerResponse response = routingContext.response();

0 commit comments

Comments
 (0)