if (log) {
logRequest(request);
}
// allow health check even without authorization
if (healthCheck(request)) {
channel.sendResponse(new BytesRestResponse(OK, "{\"OK\":{}}"));
} else if (authorized(request)) {
super.internalDispatchRequest(request, channel);
} else {
logUnAuthorizedRequest(request);
BytesRestResponse response = new BytesRestResponse(UNAUTHORIZED, "Authentication Required");
response.addHeader("WWW-Authenticate", "Basic realm=\"Restricted\"");
channel.sendResponse(response);
}
}