Skip to content

Instantly share code, notes, and snippets.

@miguelcardo
Created September 3, 2015 10:01
Show Gist options
  • Save miguelcardo/f41e85a2fd93f708b409 to your computer and use it in GitHub Desktop.
Save miguelcardo/f41e85a2fd93f708b409 to your computer and use it in GitHub Desktop.
Endpoint to serve a service description
// 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