use of com.sx4.api.exceptions.UncaughtExceptionHandler in project Sx4 by sx4-discord-bot.
the class Sx4Server method initiateWebserver.
public static void initiateWebserver(Sx4 bot) throws Exception {
ServletContextHandler contextHandler = new ServletContextHandler();
contextHandler.setContextPath("/");
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.registerInstances(new UncaughtExceptionHandler(), new YouTubeEndpoint(bot), new PatreonEndpoint(bot), new RedirectEndpoint(bot), new GitHubEndpoint(bot), new TwitterEndpoint(bot), new SteamEndpoint(bot), new TwitchEndpoint(bot));
resourceConfig.property(ServerProperties.PROCESSING_RESPONSE_ERRORS_ENABLED, true);
ServletContainer container = new ServletContainer(resourceConfig);
ServletHolder holder = new ServletHolder(container);
holder.setAsyncSupported(true);
contextHandler.addServlet(holder, "/*");
Server server = new Server();
ServerConnector connector = new ServerConnector(server);
connector.setPort(bot.getConfig().getPort());
server.setHandler(contextHandler);
server.addConnector(connector);
server.start();
}
Aggregations