'Java Http Server

I was trying to create http server in java with login system. I created code like this:

if (ServerFactory.loginStatus) {
    HttpContext mainHandler = innerServer.createContext("/l", new mainHandler());
    mainHandler.setAuthenticator(new BasicAuthenticator("l") {
        @Override
        public boolean checkCredentials(String user, String pass) {
            return user.equals(ServerFactory.login) && pass.equals(ServerFactory.password);
        }
    });
}

Without this "login system" this worked verry nice:

innerServer.createContext("/", httpExchange -> {
    Bukkit.getScheduler().runTask(Main.getPlugin(Main.class), () -> {
        All other code...

But i can't make it work with this. Problem is with executing code from handler, and make it work with bukkit. Now it create another handler, but i want it to use mainHandler()



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source