A lightweight, highly performant HTTP and WebSocket server framework for Java, designed with simplicity and efficiency in mind. Perfect for building web applications, APIs, and real-time communication systems. Heavily inspired on Express.js!
-
π HTTP Server
- Intuitive routing system with path parameters support
- Middleware chain processing
- Keep-alive connection handling
- Query parameter parsing
- Custom request/response handling
-
π‘ WebSocket Server
- Full WebSocket protocol implementation
- Multiple endpoint support
- Broadcast messaging
- Connection lifecycle management
- Automatic ping/pong handling
-
π General Features
- Thread-pooled connection handling
- Configurable server settings
- Built-in logging system
- Easy-to-use builder patterns
- Exception handling and error management
<dependency>
<groupId>io.github.lumijiez</groupId>
<artifactId>wirestream</artifactId>
<version>1.1.0</version>
</dependency>
ServerConfig config = new ServerConfig.Builder()
.port(8080)
.keepAliveTimeout(30000)
.build();
HttpServer server = new HttpServer(config);
// Add middleware
server.addMiddleware((req, res, chain) -> {
Logger.info("REQUEST", req.getMethod() + " " + req.getPath());
chain.next(req, res);
});
// Add routes
server.GET("/hello/:name", (req, res) -> {
String name = req.getPathParam("name");
res.sendResponse(HttpStatus.OK, "Hello, " + name + "!");
});
// Start the server
server.start();
WebSocketServer wsServer = new WebSocketServer(8081);
wsServer.addHandler("/chat", new WebSocketHandler() {
@Override
public void onConnect(WebSocketConnection connection) {
Logger.info("WS", "New connection: " + connection.getId());
}
@Override
public void onMessage(WebSocketConnection connection, String message) {
wsServer.broadcast("/chat", message);
}
@Override
public void onDisconnect(WebSocketConnection connection) {
Logger.info("WS", "Connection closed: " + connection.getId());
}
});
wsServer.start();
public static void main(String[] args) {
// Initialize both servers
HttpServer httpServer = new HttpServer(config);
WebSocketServer wsServer = new WebSocketServer(8081);
// Start both servers in separate threads
new Thread(httpServer::start).start();
new Thread(wsServer::start).start();
}
ServerConfig config = new ServerConfig.Builder()
.port(8080) // Server port
.keepAliveTimeout(30000) // Keep-alive timeout in ms
.maxRequestsPerConnection(1000) // Max requests per connection
.bufferSize(8192) // Buffer size in bytes
.build();
server.GET("/users/:id/posts/:postId", (req, res) -> {
String userId = req.getPathParam("id");
String postId = req.getPathParam("postId");
// Handle request...
});
server.GET("/search", (req, res) -> {
String query = req.getQueryParam("q");
String page = req.getQueryParam("page");
// Handle search...
});
wsServer.addHandler("/notifications", new WebSocketHandler() {
@Override
public void onMessage(WebSocketConnection connection, String message) {
// Broadcast to all clients on this path
wsServer.broadcast("/notifications", message);
// Or send to specific connection
connection.send("Message received!");
}
});
src/
βββ main/
β βββ java/
β βββ io/
β βββ github/
β βββ lumijiez/
β βββ core/
β β βββ config/
β β βββ http/
β β βββ logging/
β β βββ middleware/
β β βββ routing/
β β βββ util/
β β βββ ws/
β βββ example/
β βββ daos/
β βββ models/
- Java 23 or higher
- Maven 3.6 or higher
mvn clean install
mvn test
- Handles 10,000+ concurrent connections
- Low memory footprint (~50MB base)
- Quick startup time (<1 second)
- Efficient thread pool management
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by modern web frameworks
- Built with performance and simplicity in mind
- Create an issue in this repository