private String parseAndSubstitute(ServletRequest request, String path) {
        try {
            /*
              TODO(msavy): hacky... We should make UIConfig accessible here without pulling all of the world in. Issue apiman/apiman#2289

              If the user does not set `apiman-manager-ui.api.endpoint`, then we calculate a reasonable expected URL from request, and set it as
              system property `apiman-manager-ui.api.endpoint` so that the subsequent find-and-replace resolves something useful.

              This needs to be calculated as localhost is often wrong (and we do it this way for the main UI).
            */
            String defaultApiEndpoint = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/apiman";
            if (!config.containsKey("apiman-manager-ui.api.endpoint")) {
                System.setProperty("apiman-manager-ui.api.endpoint", defaultApiEndpoint);
            }
            if (!config.containsKey("apiman.auth.public.url")) {
                System.setProperty("apiman.auth.public.url", config.getString("apiman.auth.url"));
            }
            String str = FileUtils.readFileToString(resourceRoot.resolve(path).toFile(), StandardCharsets.UTF_8);
            return config.getSubstitutor().replace(str);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
@author Marc Savy {@literal <marc@blackparrotlabs.io>}
portal/war/wildfly/src/main/java/io/apiman/portal/SplitterFilter.java