public class HttpCorsServerInitializer extends ChannelInitializer<SocketChannel>
CorsConfig
javadocs for information about all the
configuration options available.
Below are some of configuration discussed in this example:
CorsConfig corsConfig = CorsConfig.withOrigin("http://domain1.com")
corsConfig.isNullOriginAllowed()
corsConfig.allowedRequestHeaders("custom-request-header")
xhr.getResponseHeader("Content-Type");If you need to get access to other headers this must be enabled by the server, for example:
corsConfig.exposedHeaders("custom-response-header");
ChannelHandler.Sharable
Constructor and Description |
---|
HttpCorsServerInitializer(SslContext sslCtx) |
Modifier and Type | Method and Description |
---|---|
void |
initChannel(SocketChannel ch)
This method will be called once the
Channel was registered. |
channelRegistered, exceptionCaught, handlerAdded, handlerRemoved
channelActive, channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, isSharable
public HttpCorsServerInitializer(SslContext sslCtx)
public void initChannel(SocketChannel ch)
ChannelInitializer
Channel
was registered. After the method returns this instance
will be removed from the ChannelPipeline
of the Channel
.initChannel
in class ChannelInitializer<SocketChannel>
ch
- the Channel
which was registered.Copyright © 2008–2020 The Netty Project. All rights reserved.