/** * {@inheritDoc} */ @Override default URI getAddress() { RatpackServer server = getServer(); try { if (!server.isRunning()) { server.start(); } return new URI(server.getScheme(), null, server.getBindHost(), server.getBindPort(), "/", null, null); } catch (Exception e) { throw uncheck(e); } }
/** * Returns the address to the root of the server, starting it if necessary. * * @return the address to the root of the server */ @Override public URI getAddress() { if (server == null) { try { server = createImpositions().impose(() -> { RatpackServer server = createServer(); server.start(); return server; }); } catch (Exception e) { throw uncheck(e); } } URI address; try { address = new URI(server.getScheme() + "://" + server.getBindHost() + ":" + server.getBindPort() + "/"); } catch (URISyntaxException e) { throw uncheck(e); } return address; }