private Route selectRoute() {
        Config config = context.getConfig();
        HttpServerRequest request = context.getRequest();
        String path = request.path();

        for (Route route : config.getRoutes().values()) {
            List<Pattern> paths = route.getPaths();
            Set<String> methods = route.getMethods();

            if (!methods.isEmpty() && !methods.contains(request.method().name())) {
                continue;
            }

            if (paths.isEmpty()) {
                return route;
            }

            for (Pattern pattern : route.getPaths()) {
                if (pattern.matcher(path).matches()) {
                    return route;
                }
            }
        }

        return null;
    }
Called when proxy failed to send response to the client.
server/src/main/java/com/epam/aidial/core/server/controller/RouteController.java