A hobby web server written in Java
I'm learning how socket communication works, and decide to rewrite my own web server for the sake of learning from (quite) literally scratch
Check out my todo list for more infos.
The jar package is currently available under Github Packages
Maven:
<dependency>
<groupId>com.github.magic</groupId>
<artifactId>magic-ws</artifactId>
<version>1.2.0</version>
</dependency>
mvn install
Gradle:
dependencies {
implementation 'com.github.magic:magic-ws:1.2.0'
}
Magic Web Server's syntax was inspired by Nodejs, therefore, you'll see the common http method verb-based approach when assigning the handler for each path
public class Main(){
public static void main(String[] args){
//Initialize the server
Server app = new Server();
//Serve "root" text at the root path
app.get("/", (req, res) -> res.send("root"));
//Listen on port 80
app.listen();
}
}
I've also prepared the examples folder with code snippet to demonstrate some cool features this web server has to offer. Make sure to check them out.
And in case you wanna add another example, feel free to make a PR and I'll have a look at it.
WIP