use of io.nuls.rpc.resources.impl.NulsResourceConfig in project nuls by nuls-io.
the class RpcServerServiceImpl method startServer.
@Override
public void startServer(String ip, int port) {
URI serverURI = UriBuilder.fromUri("http://" + ip).port(port).build();
final Map<String, Object> initParams = new HashMap<>();
initParams.put("jersey.config.server.provider.packages", RpcConstant.PACKAGES);
initParams.put("load-on-startup", "1");
NulsResourceConfig rc = new NulsResourceConfig();
rc.addProperties(initParams);
httpServer = GrizzlyHttpServerFactory.createHttpServer(serverURI, rc);
try {
httpServer.start();
ClassLoader loader = this.getClass().getClassLoader();
CLStaticHttpHandler docsHandler = new CLStaticHttpHandler(loader, "swagger-ui/");
docsHandler.setFileCacheEnabled(false);
ServerConfiguration cfg = httpServer.getServerConfiguration();
cfg.addHttpHandler(docsHandler, "/docs/");
} catch (IOException e) {
Log.error(e);
}
Log.info("http restFul server is started!url is " + serverURI.toString());
}
Aggregations