use of com.mesosphere.sdk.http.types.EndpointProducer in project dcos-commons by mesosphere.
the class EndpointsQueries method getEndpoint.
/**
* Produces the content of the specified endpoint.
*
* @param endpointName the name of the endpoint whose content should be included
*/
public static Response getEndpoint(StateStore stateStore, String frameworkName, Map<String, EndpointProducer> customEndpoints, String endpointName, SchedulerConfig schedulerConfig) {
try {
// Check for custom value before emitting any default values:
EndpointProducer customValue = customEndpoints.get(endpointName);
if (customValue != null) {
// Return custom values as plain text. They could be anything.
return plainOkResponse(customValue.getEndpoint());
}
// Fall back to checking default values:
JSONObject endpoint = getDiscoveryEndpoints(stateStore, frameworkName, schedulerConfig).get(endpointName);
if (endpoint != null) {
return jsonOkResponse(endpoint);
}
return Response.status(Response.Status.NOT_FOUND).build();
} catch (Exception ex) {
LOGGER.error(String.format("Failed to fetch endpoint %s", endpointName), ex);
return Response.serverError().build();
}
}
Aggregations