com.gateway.connector.tcp.server.HttpServerChannelInitializer Maven / Gradle / Ivy
package com.gateway.connector.tcp.server;
import com.gateway.connector.tcp.config.ServerTransportConfig;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
@ChannelHandler.Sharable
public class HttpServerChannelInitializer extends ChannelInitializer {
private ServerTransportConfig config;
public HttpServerChannelInitializer(ServerTransportConfig config) {
this.config = config;
}
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
ChannelPipeline pipeline = socketChannel.pipeline();
pipeline.addLast(new HttpServerCodec());// http
pipeline.addLast("httpAggregator", new HttpObjectAggregator(512 * 1024)); // http
pipeline.addLast(new HttpServerHandler(config));
}
}