Example usage for io.netty.handler.codec.http2 Http2MultiplexHandler Http2MultiplexHandler

List of usage examples for io.netty.handler.codec.http2 Http2MultiplexHandler Http2MultiplexHandler

Introduction

In this page you can find the example usage for io.netty.handler.codec.http2 Http2MultiplexHandler Http2MultiplexHandler.

Prototype

public Http2MultiplexHandler(ChannelHandler inboundStreamHandler) 

Source Link

Document

Creates a new instance

Usage

From source file:io.netty.example.http2.helloworld.multiplex.server.Http2OrHttpHandler.java

License:Apache License

@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
    if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
        ctx.pipeline().addLast(Http2FrameCodecBuilder.forServer().build());
        ctx.pipeline().addLast(new Http2MultiplexHandler(new HelloWorldHttp2Handler()));
        return;/*from  w ww  .  j  a  va 2 s .  com*/
    }

    if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
        ctx.pipeline().addLast(new HttpServerCodec(), new HttpObjectAggregator(MAX_CONTENT_LENGTH),
                new HelloWorldHttp1Handler("ALPN Negotiation"));
        return;
    }

    throw new IllegalStateException("unknown protocol: " + protocol);
}