public class RestController extends AbstractLifecycleComponent
lifecycle
deprecationLogger, logger, settings
Constructor and Description |
---|
RestController(Settings settings,
java.util.Set<java.lang.String> headersToCopy) |
Modifier and Type | Method and Description |
---|---|
boolean |
canTripCircuitBreaker(RestRequest request) |
void |
dispatchRequest(RestRequest request,
RestChannel channel,
NodeClient client,
ThreadContext threadContext) |
protected void |
doClose() |
protected void |
doStart() |
protected void |
doStop() |
RestFilterChain |
filterChain(RestFilter executionFilter)
Returns a filter chain with the final filter being the provided filter.
|
RestFilterChain |
filterChainOrNull(RestFilter executionFilter)
Returns a filter chain (if needed) to execute.
|
void |
registerAsDeprecatedHandler(RestRequest.Method method,
java.lang.String path,
RestHandler handler,
java.lang.String deprecationMessage,
DeprecationLogger logger)
Registers a REST handler to be executed when the provided
method and path match the request. |
void |
registerFilter(RestFilter preProcessor)
Registers a pre processor to be executed before the rest request is actually handled.
|
void |
registerHandler(RestRequest.Method method,
java.lang.String path,
RestHandler handler)
Registers a REST handler to be executed when the provided method and path match the request.
|
void |
registerWithDeprecatedHandler(RestRequest.Method method,
java.lang.String path,
RestHandler handler,
RestRequest.Method deprecatedMethod,
java.lang.String deprecatedPath,
DeprecationLogger logger)
Registers a REST handler to be executed when the provided
method and path match the request, or when provided
with deprecatedMethod and deprecatedPath . |
void |
sendErrorResponse(RestRequest request,
RestChannel channel,
java.lang.Exception e) |
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
logDeprecatedSetting, logRemovedSetting, nodeName
public RestController(Settings settings, java.util.Set<java.lang.String> headersToCopy)
protected void doStart()
doStart
in class AbstractLifecycleComponent
protected void doStop()
doStop
in class AbstractLifecycleComponent
protected void doClose()
doClose
in class AbstractLifecycleComponent
public void registerFilter(RestFilter preProcessor)
public void registerAsDeprecatedHandler(RestRequest.Method method, java.lang.String path, RestHandler handler, java.lang.String deprecationMessage, DeprecationLogger logger)
method
and path
match the request.method
- GET, POST, etc.path
- Path to handle (e.g., "/{index}/{type}/_bulk")handler
- The handler to actually executedeprecationMessage
- The message to log and send as a header in the responselogger
- The existing deprecation logger to usepublic void registerWithDeprecatedHandler(RestRequest.Method method, java.lang.String path, RestHandler handler, RestRequest.Method deprecatedMethod, java.lang.String deprecatedPath, DeprecationLogger logger)
method
and path
match the request, or when provided
with deprecatedMethod
and deprecatedPath
. Expected usage:
// remove deprecation in next major release
controller.registerWithDeprecatedHandler(POST, "/_forcemerge", this,
POST, "/_optimize", deprecationLogger);
controller.registerWithDeprecatedHandler(POST, "/{index}/_forcemerge", this,
POST, "/{index}/_optimize", deprecationLogger);
The registered REST handler (method
with path
) is a normal REST handler that is not deprecated and it is
replacing the deprecated REST handler (deprecatedMethod
with deprecatedPath
) that is using the same
handler
.
Deprecated REST handlers without a direct replacement should be deprecated directly using registerAsDeprecatedHandler(org.elasticsearch.rest.RestRequest.Method, java.lang.String, org.elasticsearch.rest.RestHandler, java.lang.String, org.elasticsearch.common.logging.DeprecationLogger)
and a specific message.
method
- GET, POST, etc.path
- Path to handle (e.g., "/_forcemerge")handler
- The handler to actually executedeprecatedMethod
- GET, POST, etc.deprecatedPath
- Deprecated path to handle (e.g., "/_optimize")logger
- The existing deprecation logger to usepublic void registerHandler(RestRequest.Method method, java.lang.String path, RestHandler handler)
method
- GET, POST, etc.path
- Path to handle (e.g., "/{index}/{type}/_bulk")handler
- The handler to actually execute@Nullable public RestFilterChain filterChainOrNull(RestFilter executionFilter)
public RestFilterChain filterChain(RestFilter executionFilter)
public boolean canTripCircuitBreaker(RestRequest request)
request
- The current request. Must not be null.public void dispatchRequest(RestRequest request, RestChannel channel, NodeClient client, ThreadContext threadContext) throws java.lang.Exception
java.lang.Exception
public void sendErrorResponse(RestRequest request, RestChannel channel, java.lang.Exception e)