io.gravitee.gateway.api.handler.Handler.handle()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中io.gravitee.gateway.api.handler.Handler.handle()方法的一些代码示例,展示了Handler.handle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handler.handle()方法的具体详情如下:
包路径:io.gravitee.gateway.api.handler.Handler
类名称:Handler
方法名:handle

Handler.handle介绍

暂无

代码示例

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
  public ReadStream<Buffer> resume() {
    endHandler.handle(null);
    return this;
  }
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
public StreamablePolicyChain write(Buffer chunk) {
  if (streamablePolicyHandlerChain != null) {
    streamablePolicyHandlerChain.write(chunk);
  } else {
    this.bodyHandler.handle(chunk);
  }
  return this;
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
  public void doNext(Request request, Response response) {
    if (policyResult.isFailure()) {
      errorHandler.handle(new PolicyChainProcessorFailure(policyResult));
    } else {
      resultHandler.handle(policyResult);
    }
  }
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
  public ReadStream<Buffer> resume() {
    if (httpClientResponse != null) {
      httpClientResponse.resume();
    } else {
      endHandler.handle(null);
    }
    return null;
  }
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
public WriteStream<Buffer> drainHandler(Handler<Void> drainHandler) {
  httpClientRequest.drainHandler(aVoid -> drainHandler.handle(null));
  return this;
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
public WriteStream<Buffer> drainHandler(Handler<Void> drainHandler) {
  httpServerResponse.drainHandler((aVoid -> drainHandler.handle(null)));
  return this;
}

代码示例来源:origin: gravitee-io/gravitee-gateway

private void sendBadGatewayResponse() {
    FailoverClientResponse response = new FailoverClientResponse();
    this.responseHandler.handle(response);
    response.endHandler().handle(null);
  }
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
public StreamableProcessor<PolicyResult> streamErrorHandler(Handler<ProcessorFailure> handler) {
  super.streamErrorHandler(processorFailure -> {
    streamErrorHandle = true;
    handler.handle(processorFailure);
  });
  return this;
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
public void process(ProcessorContext context) {
  if (isPreflightRequest(context.getRequest())) {
    handlePreflightRequest(context.getRequest(), context.getResponse());
    exitHandler.handle(null);
  } else {
    // we are in the context
    // Let's continue request processing
    handler.handle(null);
  }
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
public ReadStream<Buffer> bodyHandler(Handler<Buffer> bodyHandler) {
  this.bodyHandler = bodyHandler;
  request.bodyHandler(result -> {
    if (buffer == null) {
      buffer = Buffer.buffer();
    }
    buffer.appendBuffer(result);
    bodyHandler.handle(result);
  });
  return this;
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
public ReadStream<Buffer> bodyHandler(Handler<Buffer> bodyHandler) {
  return proxyResponse.bodyHandler(chunk -> {
    if (buffer == null) {
      buffer = Buffer.buffer();
    }
    buffer.appendBuffer(chunk);
    bodyHandler.handle(chunk);
  });
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
public void process(ProcessorContext context) {
  handleSimpleCrossOriginRequest(context.getRequest(), context.getResponse());
  handler.handle(null);
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
public ReadStream<Buffer> bodyHandler(Handler<Buffer> bodyHandler) {
  request.bodyHandler(chunk -> {
    if (buffer == null) {
      buffer = Buffer.buffer();
    }
    buffer.appendBuffer(chunk);
    bodyHandler.handle(chunk);
  });
  return this;
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
public ReadStream<Buffer> endHandler(Handler<Void> endHandler) {
  return proxyResponse.endHandler(result -> {
    if (buffer != null) {
      log.getProxyResponse().setBody(buffer.toString());
    }
    endHandler.handle(result);
  });
}

代码示例来源:origin: gravitee-io/gravitee-gateway

private void sendNotFound(Response serverResponse, Handler<Response> handler) {
  // Send a NOT_FOUND HTTP status code (404)
  serverResponse.status(HttpStatusCode.NOT_FOUND_404);
  String message = environment.getProperty("http.errors[404].message", "No context-path matches the request URI.");
  serverResponse.headers().set(HttpHeaders.CONTENT_LENGTH, Integer.toString(message.length()));
  serverResponse.headers().set(HttpHeaders.CONTENT_TYPE, "text/plain");
  serverResponse.headers().set(HttpHeaders.CONNECTION, HttpHeadersValues.CONNECTION_CLOSE);
  serverResponse.write(Buffer.buffer(message));
  serverResponse.end();
  handler.handle(serverResponse);
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
  public void handle(Response response) {
    // Compute response-time and add it to the metrics
    long proxyResponseTimeInMs = System.currentTimeMillis() - serverRequest.metrics().timestamp().toEpochMilli();
    serverRequest.metrics().setStatus(response.status());
    serverRequest.metrics().setProxyResponseTimeMs(proxyResponseTimeInMs);
    serverRequest.metrics().setProxyLatencyMs(proxyResponseTimeInMs - serverRequest.metrics().getApiResponseTimeMs());

    // Push response to the next handler
    next.handle(response);
  }
}

代码示例来源:origin: gravitee-io/gravitee-gateway

private void handleError(ProcessorContext context, ProcessorFailure failure, Handler<Response> handler) {
  StreamableProcessor<StreamableProcessor<Buffer>> errorProcessor = new ProviderProcessorChain(errorProcessors);
  errorProcessor
      .handler(__ -> {
        handleProcessorFailure(failure, context.getResponse());
        handler.handle(context.getResponse());
      })
      .process(context);
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
public Request bodyHandler(Handler<Buffer> bodyHandler) {
  httpServerRequest.handler(event -> {
    bodyHandler.handle(Buffer.buffer(event.getBytes()));
    metrics.setRequestContentLength(metrics.getRequestContentLength() + event.length());
  });
  return this;
}

代码示例来源:origin: gravitee-io/gravitee-gateway

private void handleProxyResponse(final ProcessorContext processorContext, final ProxyResponse proxyResponse, final long serviceInvocationStart, final Handler<Response> handler) {
  if (proxyResponse == null || proxyResponse instanceof DirectProxyConnection.DirectResponse) {
    processorContext.getResponse().status((proxyResponse == null) ? HttpStatusCode.SERVICE_UNAVAILABLE_503 : proxyResponse.status());
    processorContext.getResponse().end();
    handler.handle(processorContext.getResponse());
  } else {
    handleClientResponse(processorContext, proxyResponse, serviceInvocationStart, handler);
  }
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Override
  public void handle(Request request) {
    String transactionId = request.headers().getFirst(transactionHeader);
    if (transactionId == null) {
      transactionId = request.id();
      request.headers().set(transactionHeader, transactionId);
    }
    response.headers().set(transactionHeader,transactionId);

    request.metrics().setTransactionId(transactionId);
    next.handle(new TransactionRequest(transactionId, request));
  }
}

相关文章

Handler类方法