Skip to content

pk11/rxnetty-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rxnetty-router

A tiny HTTP router for [RxNetty] (https://github.com/ReactiveX/RxNetty).

rxnetty-router currently requires java8 and it's using [jauter] (https://github.com/sinetja/jauter) under the hood.

How to Install

maven:

<repositories>
    <repository>
        <id>org.pk11</id>
        <url>http://pk11-scratch.googlecode.com/svn/trunk</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.pk11.rxnetty</groupId>
        <artifactId>rxnetty-router</artifactId>
        <version>0.1</version>
    </dependency>
</dependencies>

Example

import static org.pk11.rxnetty.router.Dispatch.using;
import static org.pk11.rxnetty.router.Dispatch.withParams;
(...)
HttpServer<ByteBuf, ByteBuf> server = RxNetty.createHttpServer(0, using(
					new Router<ByteBuf, ByteBuf>() 
					.GET("/hello", new HelloHandler())
					.GET("/article/:id", withParams( (params, request, response)->{
						response.setStatus(HttpResponseStatus.OK);
            			response.writeString("params:"+ params.get("id"));
            			return response.close();
					}))
					.GET("/public/:*", new ClassPathFileRequestHandler("www"))
					.notFound(new Handler404())
					)).start();

See RouterTest for a full example.

About

A tiny HTTP Router for RxNetty

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages