- 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 void
channelRead(ChannelHandlerContext ctx, Object msg)
Invoked when the currentChannel
has 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 ofCorsConfig
isShortCircuit
- 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:ChannelHandler
Invoked when the currentChannel
has read a message from the peer.- Specified by:
channelRead
in interfaceChannelHandler
- Throws:
Exception
-
write
public Future<Void> write(ChannelHandlerContext ctx, Object msg)
Description copied from interface:ChannelHandler
Called once a write operation is made. The write operation will write the messages through theChannelPipeline
. Those are then ready to be flushed to the actualChannel
onceChannel.flush()
is called.- Specified by:
write
in interfaceChannelHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the write operation is mademsg
- the message to write- Returns:
- the
Future
which will be notified once the operation completes.
-
-