configureAsyncHTTPServerPipeline(http2Configuration:http1ConnectionInitializer:http2ConnectionInitializer:http2StreamInitializer:)

Configures a ChannelPipeline to speak either HTTP/1.1 or HTTP/2 according to what can be negotiated with the client.

HTTP2PipelineHelpers.swift:692
iOS
13.0+
macOS
10.15+
tvOS
13.0+
watchOS
6.0+
func configureAsyncHTTPServerPipeline<HTTP1ConnectionOutput, HTTP2ConnectionOutput, HTTP2StreamOutput>(http2Configuration: NIOHTTP2Handler.Configuration = .init(), http1ConnectionInitializer: @escaping NIOChannelInitializerWithOutput<HTTP1ConnectionOutput>, http2ConnectionInitializer: @escaping NIOChannelInitializerWithOutput<HTTP2ConnectionOutput>, http2StreamInitializer: @escaping NIOChannelInitializerWithOutput<HTTP2StreamOutput>) -> EventLoopFuture<EventLoopFuture<NIONegotiatedHTTPVersion<HTTP1ConnectionOutput, (HTTP2ConnectionOutput, NIOHTTP2Handler.AsyncStreamMultiplexer<HTTP2StreamOutput>)>>> where HTTP1ConnectionOutput : Sendable, HTTP2ConnectionOutput : Sendable, HTTP2StreamOutput : Sendable

Parameters

http2Configuration

The settings that will be used when establishing the HTTP/2 connections and new HTTP/2 streams.

http1ConnectionInitializer

An optional callback that will be invoked only when the negotiated protocol is HTTP/1.1 to configure the connection channel.

http2ConnectionInitializer

An optional callback that will be invoked only when the negotiated protocol is HTTP/2 to configure the connection channel. The channel has an ChannelOutboundHandler/OutboundIn type of HTTP2Frame.

http2StreamInitializer

A closure that will be called whenever the remote peer initiates a new stream. The output of this closure is the element type of the returned multiplexer

Returns

An EventLoopFuture containing a NIOTypedApplicationProtocolNegotiationHandler that completes when the channel is ready to negotiate. This can then be used to access the NIOProtocolNegotiationResult which may itself be waited on to retrieve the result of the negotiation.

This helper takes care of configuring the server pipeline such that it negotiates whether to use HTTP/1.1 or HTTP/2.

This function doesn’t configure the TLS handler. Callers of this function need to add a TLS handler appropriately configured to perform protocol negotiation.