class ResponseDtoValidator extends ResponseEntityExceptionHandler {

    String getResourceName(WebRequest request) {
        String description = request.getDescription(false);
        String[] uriParts = description.split("/");
        String resourceName;
        if (uriParts.length >= 5) {
            resourceName = uriParts[4];
        } else if (uriParts.length >= 3) {
            resourceName = uriParts[2];
            // TODO Will return plural version ("countries" instead of "country")
        } else {
            log.error("No resource in {}", description);
            resourceName = "unknown";
        }
        return resourceName;
    }

}