rxnetty-rest-router

null

License

License

Categories

Categories

Net Netty Networking
GroupId

GroupId

com.github.diegopacheco
ArtifactId

ArtifactId

rxnetty-rest-router
Last Version

Last Version

0.2
Release Date

Release Date

Type

Type

jar
Description

Description

rxnetty-rest-router
null
Project URL

Project URL

https://github.com/diegopacheco/rxnetty-rest-router
Source Code Management

Source Code Management

https://github.com/diegopacheco/rxnetty-rest-router.git

Download rxnetty-rest-router

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.diegopacheco/rxnetty-rest-router/ -->
<dependency>
    <groupId>com.github.diegopacheco</groupId>
    <artifactId>rxnetty-rest-router</artifactId>
    <version>0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.diegopacheco/rxnetty-rest-router/
implementation 'com.github.diegopacheco:rxnetty-rest-router:0.2'
// https://jarcasting.com/artifacts/com.github.diegopacheco/rxnetty-rest-router/
implementation ("com.github.diegopacheco:rxnetty-rest-router:0.2")
'com.github.diegopacheco:rxnetty-rest-router:jar:0.2'
<dependency org="com.github.diegopacheco" name="rxnetty-rest-router" rev="0.2">
  <artifact name="rxnetty-rest-router" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.diegopacheco', module='rxnetty-rest-router', version='0.2')
)
libraryDependencies += "com.github.diegopacheco" % "rxnetty-rest-router" % "0.2"
[com.github.diegopacheco/rxnetty-rest-router "0.2"]

Dependencies

compile (6)

Group / Artifact Type Version
io.reactivex : rxnetty jar 0.5.1
com.google.inject : guice jar 4.1.0
org.glassfish.jersey.core : jersey-server jar 2.7
org.glassfish.jersey.containers : jersey-container-servlet-core jar 2.7
org.glassfish.jersey.containers : jersey-container-jetty-http jar 2.7
org.slf4j : slf4j-log4j12 jar 1.7.25

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

rxnetty-rest-router

This project is a simple sample of a JAX-RS Jesery router for RxNetty Server.

Features

  • RxNetty Builder
  • Jersey Router
  • Support for @PathParam annotation in class and method level.
  • Converts results to observables if they are not Observables.
  • Guice 4 Integration and Support
  • Inject Request and Response parameters if method signature present.

Future Work(Pending)

  • Add Suport for @QueryParam
  • Add Support other typez like Long, Double and Boolean

Usage

You can find the jar at sonatype central repository https://oss.sonatype.org/service/local/repositories/releases/content/com/github/diegopacheco/rxnetty-rest-router/0.2/

Maven

<dependency>
  <groupId>com.github.diegopacheco</groupId>
  <artifactId>rxnetty-rest-router</artifactId>
  <version>0.2</version>
</dependency>

Gradle

dependencies {
	compile([
	       'com.github.diegopacheco:rxnetty-rest-router:0.2'
        ])
}

Sample

ServerApp.java

public class ServerApp{
   public static void main(String[] args){
       new RxNettyServerBuilder()
        .withPort(9090)
        .withPackages("com.github.diegopacheco.rxnetty.builder.test")
        .withModules(new Module[]{new GuiceModule()})
        .start();
   }
}

GuiceModule

import com.google.inject.AbstractModule;

public class GuiceModule extends AbstractModule{

	@Override
	protected void configure() {
		bind(RestInfo.class).asEagerSingleton();
	}

}

RestInfo.java

import javax.ws.rs.GET;
import javax.ws.rs.Path;

import io.netty.buffer.ByteBuf;
import io.reactivex.netty.protocol.http.server.HttpServerRequest;
import io.reactivex.netty.protocol.http.server.HttpServerResponse;
import rx.Observable;

@Path("/info")
public class RestInfo {

   @GET
   @Path("rr")
   public Observable<String> workObRes(HttpServerRequest<ByteBuf> req,HttpServerResponse<ByteBuf> resp){
	resp.setHeader("CREATED_BY", "DIEGO");
	return Observable.just("OKReqResp");
   }

   @GET
   @Path("now")
   public String work(){
	return "OK";
   }

  @GET
  @Path("path/{a}/{b}")
  public String query(@PathParam("a") String a, @PathParam("b") String b){
       return "Path: " +  a + " - " + b;
  }

}

Testing

curl -v http://127.0.0.1:9090/info/now
curl -v http://127.0.0.1:9090/info/rr
curl -v http://127.0.0.1:9090/info/path/10/6

Release

0.2

  • Support for @PathParam annotation in class and method level.

0.1

  • RxNetty Builder
  • Jersey Router
  • Converts results to observables if they are not Observables.
  • Guice 4 Integration and Support
  • Inject Request and Response parameters if method signature present.

Cheers,
Diego Pacheco

Versions

Version
0.2
0.1