Example usage for io.netty.handler.codec.http2 Http2MultiplexCodecBuilder forServer

List of usage examples for io.netty.handler.codec.http2 Http2MultiplexCodecBuilder forServer

Introduction

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

Prototype

public static Http2MultiplexCodecBuilder forServer(ChannelHandler childHandler) 

Source Link

Document

Creates a builder for an HTTP/2 server.

Usage

From source file: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(Http2MultiplexCodecBuilder.forServer(new HelloWorldHttp2Handler()).build());
        return;/*  w  w w . j a v a 2  s  .co  m*/
    }

    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);
}