Class CorsHandler

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

    public class CorsHandler
    extends io.netty.channel.ChannelDuplexHandler
    Handles Cross Origin Resource Sharing (CORS) requests.

    This handler can be configured using one or more CorsConfig, please refer to this class for details about the configuration options available. NOTE: This class should be removed after https://github.com/netty/netty/issues/10381 is solved.

    • Constructor Summary

      Constructors 
      Constructor Description
      CorsHandler​(io.netty.handler.codec.http.cors.CorsConfig config)
      Creates a new instance with a single CorsConfig.
      CorsHandler​(List<io.netty.handler.codec.http.cors.CorsConfig> configList, boolean isShortCircuit)
      Creates a new instance with the specified config list.
    • Constructor Detail

      • CorsHandler

        public CorsHandler​(io.netty.handler.codec.http.cors.CorsConfig config)
        Creates a new instance with a single CorsConfig.
      • CorsHandler

        public CorsHandler​(List<io.netty.handler.codec.http.cors.CorsConfig> configList,
                           boolean isShortCircuit)
        Creates a new instance with the specified config list. If more than one config matches a certain origin, the first in the List will be used.
        Parameters:
        configList - List of CorsConfig
        isShortCircuit - Same as CorsConfig.shortCircuit but applicable to all supplied configs.
    • Method Detail

      • channelRead

        public void channelRead​(io.netty.channel.ChannelHandlerContext ctx,
                                Object msg)
                         throws Exception
        Throws:
        Exception
      • write

        public void write​(io.netty.channel.ChannelHandlerContext ctx,
                          Object msg,
                          io.netty.channel.ChannelPromise promise)
                   throws Exception
        Throws:
        Exception