private boolean shouldProceed(RestRequest restRequest, RestResponseChannel restResponseChannel) {
    if (blocking) {
      try {
        blockLatch.await();
      } catch (InterruptedException e) {
        throw new IllegalStateException(e);
      }
    }
    boolean shouldProceed = canHonorRequest(restRequest, restResponseChannel);
    if (shouldProceed) {
      String uri = restRequest.getUri();
      ReadableStreamChannel response = null;
      Exception exception = null;
      if (uri.startsWith(ECHO_REST_METHOD)) {
        String responseStr = restRequest.getRestMethod().toString() + uri.substring(ECHO_REST_METHOD.length());
        ByteBuffer buffer = ByteBuffer.wrap(responseStr.getBytes());
        response = new ByteBufferRSC(buffer);
        shouldProceed = false;
      } else if (THROW_RUNTIME_EXCEPTION.equals(uri)) {
        throw new RuntimeException(THROW_RUNTIME_EXCEPTION);
      } else if (SEND_RESPONSE_RUNTIME_EXCEPTION.equals(uri)) {
        shouldProceed = false;
        exception = new RuntimeException(SEND_RESPONSE_RUNTIME_EXCEPTION);
      } else if (SEND_RESPONSE_REST_SERVICE_EXCEPTION.equals(uri)) {
        shouldProceed = false;
        RestServiceErrorCode errorCode = RestServiceErrorCode.InternalServerError;
        try {
          errorCode = RestServiceErrorCode.valueOf(verifiableProperties.getString(REST_ERROR_CODE));
        } catch (IllegalArgumentException e) {
          // it's alright.
        }
        exception = new RestServiceException(SEND_RESPONSE_REST_SERVICE_EXCEPTION, errorCode);
      }
      if (!shouldProceed) {
        try {
          if (exception == null) {
            restResponseChannel.setStatus(ResponseStatus.Ok);
          }
        } catch (RestServiceException e) {
          exception = e;
        } finally {
          handleResponse(restRequest, restResponseChannel, response, exception);
        }
      }
    }
    return shouldProceed;
  }
Handles argument pre-checks and examines the URL to see if any custom operations need to be performed (which might
involve throwing exceptions).
<p/>
Also blocks if required.
@param restRequest the {@link RestRequest} that needs to be handled.
@param restResponseChannel the {@link RestResponseChannel} that can be used to set headers.
@return {@code true} if the pre-checks decided it is OK to continue. Otherwise {@code false}.
ambry-api/src/test/java/com/github/ambry/rest/MockRestRequestService.java