Package com.netflix.zuul.filters
Class BaseFilter<I extends ZuulMessage,O extends ZuulMessage>
java.lang.Object
com.netflix.zuul.filters.BaseFilter<I,O>
- All Implemented Interfaces:
ShouldFilter<I>
,ZuulFilter<I,
O>
- Direct Known Subclasses:
BaseSyncFilter
,Endpoint
,HttpInboundFilter
,HttpOutboundFilter
public abstract class BaseFilter<I extends ZuulMessage,O extends ZuulMessage>
extends Object
implements ZuulFilter<I,O>
Base abstract class for ZuulFilters. The base class defines abstract methods to define:
filterType() - to classify a filter by type. Standard types in Zuul are "pre" for pre-routing filtering,
"route" for routing to an origin, "post" for post-routing filters, "error" for error handling.
We also support a "static" type for static responses see StaticResponseFilter.
filterOrder() must also be defined for a filter. Filters may have the same filterOrder if precedence is not important for a filter. filterOrders do not need to be sequential.
ZuulFilters may be disabled using Archaius Properties.
By default ZuulFilters are static; they don't carry state. This may be overridden by overriding the isStaticFilter() property to false
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called by zuul filter after request is processed by this filter.The name of the Archaius property to disable this filter.getDefaultOutput
(I input) Choose a default message to use if the applyAsync() method throws an exception.void
Called by zuul filter runner before sending request through this filter.boolean
If true, the filter has been disabled by archaius and will not be run.The name of the Archaius property for this filter's max concurrency.boolean
needsBodyBuffered
(I input) Filter indicates it needs to read and buffer whole body before it can operate on the messages by returning true.boolean
Whether this filter's shouldFilter() method should be checked, and apply() called, even if SessionContext.stopFilterProcessing has been set.io.netty.handler.codec.http.HttpContent
processContentChunk
(ZuulMessage zuulMessage, io.netty.handler.codec.http.HttpContent chunk) Optionally transform HTTP content chunk received.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.netflix.zuul.filters.ShouldFilter
shouldFilter
Methods inherited from interface com.netflix.zuul.filters.ZuulFilter
applyAsync, category, filterOrder, filterType
-
Constructor Details
-
BaseFilter
protected BaseFilter()
-
-
Method Details
-
filterName
- Specified by:
filterName
in interfaceZuulFilter<I extends ZuulMessage,
O extends ZuulMessage>
-
overrideStopFilterProcessing
public boolean overrideStopFilterProcessing()Description copied from interface:ZuulFilter
Whether this filter's shouldFilter() method should be checked, and apply() called, even if SessionContext.stopFilterProcessing has been set.- Specified by:
overrideStopFilterProcessing
in interfaceZuulFilter<I extends ZuulMessage,
O extends ZuulMessage> - Returns:
- boolean
-
disablePropertyName
The name of the Archaius property to disable this filter. by default it is zuul.[classname].[filtertype].disable -
maxConcurrencyPropertyName
The name of the Archaius property for this filter's max concurrency. by default it is zuul.[classname].[filtertype].concurrency.limit -
isDisabled
public boolean isDisabled()If true, the filter has been disabled by archaius and will not be run.- Specified by:
isDisabled
in interfaceZuulFilter<I extends ZuulMessage,
O extends ZuulMessage>
-
getDefaultOutput
Description copied from interface:ZuulFilter
Choose a default message to use if the applyAsync() method throws an exception.- Specified by:
getDefaultOutput
in interfaceZuulFilter<I extends ZuulMessage,
O extends ZuulMessage> - Returns:
- ZuulMessage
-
getSyncType
- Specified by:
getSyncType
in interfaceZuulFilter<I extends ZuulMessage,
O extends ZuulMessage>
-
toString
-
needsBodyBuffered
Description copied from interface:ZuulFilter
Filter indicates it needs to read and buffer whole body before it can operate on the messages by returning true. The decision can be made at runtime, looking at the request type. For example if the incoming message is a MSL message MSL decryption filter can return true here to buffer whole MSL message before it tries to decrypt it.- Specified by:
needsBodyBuffered
in interfaceZuulFilter<I extends ZuulMessage,
O extends ZuulMessage> - Returns:
- true if this filter needs to read whole body before it can run, false otherwise
-
processContentChunk
public io.netty.handler.codec.http.HttpContent processContentChunk(ZuulMessage zuulMessage, io.netty.handler.codec.http.HttpContent chunk) Description copied from interface:ZuulFilter
Optionally transform HTTP content chunk received.- Specified by:
processContentChunk
in interfaceZuulFilter<I extends ZuulMessage,
O extends ZuulMessage>
-
incrementConcurrency
Description copied from interface:ZuulFilter
Called by zuul filter runner before sending request through this filter. The filter can throw ZuulFilterConcurrencyExceededException if it has reached its concurrent requests limit and does not wish to process the request. Generally only useful for async filters.- Specified by:
incrementConcurrency
in interfaceZuulFilter<I extends ZuulMessage,
O extends ZuulMessage> - Throws:
ZuulFilterConcurrencyExceededException
-
decrementConcurrency
public void decrementConcurrency()Description copied from interface:ZuulFilter
Called by zuul filter after request is processed by this filter.- Specified by:
decrementConcurrency
in interfaceZuulFilter<I extends ZuulMessage,
O extends ZuulMessage>
-