Created
September 3, 2015 10:01
-
-
Save miguelcardo/f41e85a2fd93f708b409 to your computer and use it in GitHub Desktop.
Endpoint to serve a service description
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
// Endpoint for the service description. | |
get(new Route("/describe/:serviceId") { | |
@Override | |
public Object handle(Request request, Response response) { | |
String serviceId = request.params("serviceId"); | |
System.out.println("DESCRIBE endpoint - ServiceID: " + serviceId); | |
JSONObject description = new JSONObject(); | |
// verify the serviceId | |
if (serviceId.equals(Constants.invokeServiceId)){ | |
description.put("title", Constants.invokeServiceTitle); | |
} else if (serviceId.equals(Constants.deleteServiceId)) { | |
description.put("title", Constants.deleteServiceTitle); | |
} else { | |
response.status(HTTP_NOT_FOUND); | |
return "HTTP 404 - Service not found"; | |
} | |
description.put("confirmationRequired", Constants.requiresConfirmation); | |
response.type("application/json"); | |
response.status(HTTP_OK); | |
return description.toJSONString(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment