- java.lang.Object
-
- io.netty5.handler.codec.http.cors.CorsHandler
-
- All Implemented Interfaces:
ChannelHandler
public class CorsHandler extends Object implements ChannelHandler
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.
-
-
Constructor Summary
Constructors Constructor Description CorsHandler(CorsConfig config)Creates a new instance with a singleCorsConfig.CorsHandler(List<CorsConfig> configList, boolean isShortCircuit)Creates a new instance with the specified config list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelRead(ChannelHandlerContext ctx, Object msg)Invoked when the currentChannelhas read a message from the peer.Future<Void>write(ChannelHandlerContext ctx, Object msg)Called once a write operation is made.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelExceptionCaught, channelInactive, channelInboundEvent, channelReadComplete, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerAdded, handlerRemoved, isSharable, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown
-
-
-
-
Constructor Detail
-
CorsHandler
public CorsHandler(CorsConfig config)
Creates a new instance with a singleCorsConfig.
-
CorsHandler
public CorsHandler(List<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 ofCorsConfigisShortCircuit- Same asCorsConfig.isShortCircuit()but applicable to all supplied configs.
-
-
Method Detail
-
channelRead
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
Description copied from interface:ChannelHandlerInvoked when the currentChannelhas read a message from the peer.- Specified by:
channelReadin interfaceChannelHandler- Throws:
Exception
-
write
public Future<Void> write(ChannelHandlerContext ctx, Object msg)
Description copied from interface:ChannelHandlerCalled once a write operation is made. The write operation will write the messages through theChannelPipeline. Those are then ready to be flushed to the actualChannelonceChannel.flush()is called.- Specified by:
writein interfaceChannelHandler- Parameters:
ctx- theChannelHandlerContextfor which the write operation is mademsg- the message to write- Returns:
- the
Futurewhich will be notified once the operation completes.
-
-