Project

thick

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Very lightweight web server for JRuby based on Netty library.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 10
>= 2

Runtime

= 1.5.2
 Project Readme

WildWeb

Netty-based HTTP server framework. Embeds Thick - a lightweight web server for JRuby.

Example

package cz.wildweb.example;

import cz.wildweb.api.HttpServer;
import cz.wildweb.api.WebSocket;
import cz.wildweb.server.netty.NettyServer;

public class Main {

    public static void main(String[] args) {
        HttpServer server = new NettyServer();
        server.start("localhost", 8081);

        server.register("/", (request, response) -> {
            response.close("Hello");
        });

        server.register("/echo/:content", (request, response) -> {
            response.close(request.attribute("content"));
        });

        server.register("/print/*", (request, response) -> {
            response.close(request.splat());
        });

        server.register("/print/*/inside", (request, response) -> {
            response.close("Inside: " + request.splat());
        });

        server.register("/websocket", ((request, response) -> {
            if(request.websocket().valid()) {
                WebSocket socket = request.websocket();
                socket.opened(() -> {
                });
                socket.message(message -> {
                    socket.write(message);
                });
                socket.closed(() -> {
                });

                socket.accept();
            } else {
                response.render("websocket.ftl");
            }
        }));
    }

}

or

package cz.wildweb.example;

import static cz.wildweb.api.Wildweb.*;

public class Main {

    public static void main(String[] args) {
        get("/", (req, res) -> { res.close("Welcome"); });
        startServer(8080);
    }

}

or

package cz.wildweb.example;

import static cz.wildweb.api.Wildweb.*;

public class Main {

    public static void main(String[] args) {
        request(new RootHandler());
        startServer(8080);
    }

}
package cz.wildweb.example;

import cz.wildweb.api.HttpHandler;
import cz.wildweb.api.HttpRequest;
import cz.wildweb.api.HttpResponse;
import cz.wildweb.api.annotations.Request;

@Request(url = "/")
public class RootHandler implements HttpHandler {
    @Override
    public void handle(HttpRequest request, HttpResponse response) throws Exception {
        response.close("Welcome.");
    }
}

Status

Simple prototype, the routing system is everything but optimal, no tests, etc.

License

WildWeb is released under the MIT License.