Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stonyshi/reactor-netty-ext
reactor-netty-ext
https://github.com/stonyshi/reactor-netty-ext
http-server jersey netty reactor
Last synced: 24 days ago
JSON representation
reactor-netty-ext
- Host: GitHub
- URL: https://github.com/stonyshi/reactor-netty-ext
- Owner: StonyShi
- Created: 2018-01-23T10:37:26.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-13T05:56:18.000Z (almost 6 years ago)
- Last Synced: 2024-10-12T06:40:26.634Z (24 days ago)
- Topics: http-server, jersey, netty, reactor
- Language: Java
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### reactor-netty-ext
#### 1. [reactor-netty](https://github.com/reactor/reactor-netty) jersey1.x的扩展
#### 2. 扩展get方法支持get?p=1 的方式访问
#### 3. 支持静态资源不加配置前缀(如不加: `/res` )
#### 4. 增加对原有路由全桥接,支持静态文件访问
### 代码示例:
```com.github.stonyshi
reactor-netty-ext
1.0.2```
```
final Path resource = Paths.get(NettyServerTest.class.getResource("/public").toURI());
HttpServer.create(8080)
.startAndAwait(JerseyBasedHandler.builder()
.withClassPath("com.stoney.reactor.jerysey.router")
.addValueProvider(JacksonProvider.class)
.addRouter(routes -> {
routes.get("/get", (req, resp) -> resp.sendString(Mono.just("asdfasdf")))
.directory("/res", resource);
}).build()
);@Path("/api")
public class ServiceHot {
@POST()
@Path("/post")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public UserTest post(UserTest body) {
System.out.println("body = " + body);
return new UserTest("bai", 200, "li");
}
@GET()
@Path("/get")
@Produces(MediaType.APPLICATION_JSON)
public UserTest get() {
return new UserTest("bai", 199, "li");
}
}curl -X POST \
http://localhost:8080/hot/post \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: f202fc59-94b9-f0e3-307d-35cb0fe885d6' \
-d '{"first_name":"li","name":"jiu","id":200}'{
"name": "bai",
"id": 200,
"first_name": "li"
}
```
##test
```wrk -H 'Connection: keep-alive' -t12 -c400 -d30s http://localhost:8082/get
Running 30s test @ http://localhost:8082/get
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 6.99ms 31.79ms 892.82ms 99.18%
Req/Sec 7.29k 0.93k 23.47k 93.04%
2606144 requests in 30.10s, 248.54MB read
Requests/sec: 86582.83
Transfer/sec: 8.26MBwrk -H 'Connection: keep-alive' -t20 -c400 -d30s http://localhost:8082/api/get?id=3887099059629981696
Running 30s test @ http://localhost:8082/api/get?id=3887099059629981696
20 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 54.04ms 9.31ms 142.88ms 71.88%
Req/Sec 370.86 53.38 676.00 71.84%
221881 requests in 30.08s, 107.92MB read
Socket errors: connect 0, read 221881, write 0, timeout 0
Requests/sec: 7376.17
Transfer/sec: 3.59MB
```