in iep-admin/src/main/java/com/netflix/iep/admin/RequestHandler.java [45:73]
public void handle(HttpExchange exchange) throws IOException {
// Get everything after the path prefix used for the context
String reqPath = exchange.getRequestURI().getPath();
String id = (path.length() == reqPath.length()) ? null : reqPath.substring(path.length());
if (id != null && !id.startsWith("/")) {
// Should start with a '/', otherwise return a 404
sendResponse(exchange, new ErrorMessage(404, reqPath));
} else {
// Get id, everything after the starting '/'
id = (id == null || "/".equals(id)) ? null : id.substring(1);
try {
Object obj = (id == null) ? endpoint.get() : endpoint.get(id);
if (obj == null)
sendResponse(exchange, new ErrorMessage(404, reqPath));
else
handleImpl(exchange, obj);
} catch (HttpException e) {
LOGGER.debug("request failed: " + reqPath, e);
sendResponse(exchange, new ErrorMessage(e.getStatus(), e.getCause()));
} catch (IllegalArgumentException | IllegalStateException e) {
LOGGER.debug("request failed: " + reqPath, e);
sendResponse(exchange, new ErrorMessage(400, e));
} catch (Exception e) {
LOGGER.debug("request failed: " + reqPath, e);
sendResponse(exchange, new ErrorMessage(500, e));
}
}
}