https://github.com/shantanu-verma-salpro/miniweb
HTTP server in java using NIO , Multi reactor
https://github.com/shantanu-verma-salpro/miniweb
http-server httpserver java nio router
Last synced: about 1 year ago
JSON representation
HTTP server in java using NIO , Multi reactor
- Host: GitHub
- URL: https://github.com/shantanu-verma-salpro/miniweb
- Owner: shantanu-verma-salpro
- Created: 2023-07-17T16:17:15.000Z (almost 3 years ago)
- Default Branch: miniwebframework
- Last Pushed: 2023-10-07T11:44:23.000Z (over 2 years ago)
- Last Synced: 2024-12-26T12:11:23.389Z (over 1 year ago)
- Topics: http-server, httpserver, java, nio, router
- Language: Java
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MiniWeb 🌐
MiniWeb is a minimalist web server implemented in Java, utilizing the Non-blocking I/O (NIO) and the Multi-Reactor pattern to efficiently handle network events in a scalable manner.
## Features ✨
- **Non-blocking I/O (NIO)**: Efficient handling of network events with Java NIO.
- **Multi-Reactor Pattern**: Enhanced scalability and performance by employing a multi-reactor pattern.
- **Trie-based Routing**: Utilizes a trie for efficient routing and URL matching.
## Usage 🚀
### 1. Define Your Handlers:
```java
public static class BookController {
public static HttpResponse handleGetAll(HttpRequest req, PathParameters p) {
// Handle GET request for all books
String responseString = "Handling GET all books";
return new HttpResponse.Builder()
.statusCode(200)
.body(responseString)
.build();
}
}
```
### 2. Route and Start the Server:
```cpp
public class App {
public static void main(String[] args) throws IOException {
MiniServer x = new MiniServer();
x.route("/books", HttpMethod.GET, BookController::handleGetAll);
x.start();
}
}
```
## Installation 🛠️
Compile and run the project using your favorite IDE or via the command line.
## Contributing 🤝
Contributions are welcome! Feel free to open a PR or submit issues for any bugs or enhancements.
## License 📄
This project is open-source and available under the MIT License.