/netty-example

Netty web project

Primary LanguageJava

netty-example

Example web server using Netty, inspired by Spark

Java Example

public class App {
    public static void main(final String[] args) throws Exception {
        new WebServer()

                // Simple GET request
                .get("/hello", (request, response) -> "Hello world")

                // Simple POST request
                .post("/hello", (request, response) -> {
                    return "Hello world: " + request.body();
                })

                // Start the server
                .start();
    }
}

Groovy Example

import nettyexample.server.*

new WebServer()
    // Simple GET request
    .get("/hello", (request, response) -> "Hello world")

    // Simple POST request
    .post("/hello", (request, response) -> {
          return "Hello world: " + request.body()
    })

    // Start the server
    .start()