Skip to content

Commit 790c7fe

Browse files
committed
netty: more code cleanup
1 parent 1a03a6f commit 790c7fe

File tree

4 files changed

+11
-38
lines changed

4 files changed

+11
-38
lines changed

modules/jooby-netty/src/main/java/io/jooby/internal/netty/NettyHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
7171
}
7272
context.setHeaders.set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN);
7373

74-
if (req.method().equals(HttpMethod.GET)) {
74+
if (req.method() == HttpMethod.GET) {
7575
router.match(context).execute(context);
7676
} else {
7777
// possibly body:

modules/jooby-netty/src/main/java/io/jooby/internal/netty/NettyPipeline.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private void http11Upgrade(
119119

120120
private void http11(ChannelPipeline p) {
121121
p.addLast("decoder", new NettyRequestDecoder(decoderConfig));
122-
p.addLast("encoder", new NettyResponseEncoder());
122+
p.addLast("encoder", new HttpResponseEncoder());
123123
additionalHandlers(p);
124124
p.addLast("handler", createHandler());
125125
}

modules/jooby-netty/src/main/java/io/jooby/internal/netty/NettyRequestDecoder.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
public class NettyRequestDecoder extends HttpRequestDecoder {
1111

12+
private static final String GET = HttpMethod.GET.name();
13+
private static final String POST = HttpMethod.POST.name();
14+
private static final String PUT = HttpMethod.PUT.name();
15+
private static final String DELETE = HttpMethod.DELETE.name();
16+
1217
public NettyRequestDecoder(HttpDecoderConfig config) {
1318
super(config);
1419
}
@@ -24,16 +29,16 @@ protected HttpMessage createMessage(String[] initialLine) throws Exception {
2429

2530
private static HttpMethod valueOf(String name) {
2631
// fast-path
27-
if (name == HttpMethod.GET.name()) {
32+
if (name == GET) {
2833
return HttpMethod.GET;
2934
}
30-
if (name == HttpMethod.POST.name()) {
35+
if (name == POST) {
3136
return HttpMethod.POST;
3237
}
33-
if (name == HttpMethod.DELETE.name()) {
38+
if (name == DELETE) {
3439
return HttpMethod.DELETE;
3540
}
36-
if (name == HttpMethod.PUT.name()) {
41+
if (name == PUT) {
3742
return HttpMethod.PUT;
3843
}
3944
// "slow"-path: ensure method is on upper case

modules/jooby-netty/src/main/java/io/jooby/internal/netty/NettyResponseEncoder.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)