HTTPdLib v0.1.0
This is the first public release of the library, it has been heavily tested but please feel free to report any issues found.
To add it as a…
Read MorePublished 03/22/2023
Build your own HTTP server using HTTPdLib - An easy-to-use zero dependency non-blocking HTTP web server for Java.
Add the following to your pom.xml as a maven dependency, or just download the latest release and import it with your IDE.
<dependency>
<groupId>com.konloch</groupId>
<artifactId>HTTPdLib</artifactId>
<version>0.1.0</version>
</dependency>
Click here to view an example of how to implement the HTTP server.
import com.konloch.disklib.DiskReader;
import com.konloch.http.HTTPdLib;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* @author Konloch
* @since 2/28/2023
*/
public class TestHTTPServer
{
public static void main(String[] args) throws IOException
{
HTTPdLib webserver = new HTTPdLib(80, request ->
{
switch(request.getPath())
{
case "/":
return ("Hello World: " + request.getRemoteIP()).getBytes(StandardCharsets.UTF_8);
}
});
webserver.start();
System.out.println("Running on http://localhost:" + webserver.getServer().getPort() + "/");
}
}
This is the first public release of the library, it has been heavily tested but please feel free to report any issues found.
To add it as a…
Read More