io.micronaut.http.HttpRequest.getMethod()方法的使用及代码示例

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

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

HttpRequest.getMethod介绍

暂无

代码示例

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public HttpMethod getMethod() {
  return getDelegate().getMethod();
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
   * @param request The {@link HttpRequest} object
   * @return Return whether this request is a pre-flight request
   */
  static boolean isPreflightRequest(HttpRequest request) {
    HttpHeaders headers = request.getHeaders();
    Optional<String> origin = headers.getOrigin();
    return origin.isPresent() && headers.contains(ACCESS_CONTROL_REQUEST_METHOD) && HttpMethod.OPTIONS == request.getMethod();
  }
}

代码示例来源:origin: micronaut-projects/micronaut-core

private void traceRequest(io.micronaut.http.HttpRequest<?> request, io.netty.handler.codec.http.HttpRequest nettyRequest) {
  HttpHeaders headers = nettyRequest.headers();
  traceHeaders(headers);
  if (io.micronaut.http.HttpMethod.permitsRequestBody(request.getMethod()) && request.getBody().isPresent() && nettyRequest instanceof FullHttpRequest) {
    FullHttpRequest fullHttpRequest = (FullHttpRequest) nettyRequest;
    ByteBuf content = fullHttpRequest.content();
    if (log.isTraceEnabled()) {
      traceBody("Request", content);
    }
  }
}

代码示例来源:origin: micronaut-projects/micronaut-core

private <I> NettyRequestWriter prepareRequest(io.micronaut.http.HttpRequest<I> request, URI requestURI) throws HttpPostRequestEncoder.ErrorDataEncoderException {
  MediaType requestContentType = request
      .getContentType()
      .orElse(MediaType.APPLICATION_JSON_TYPE);
  boolean permitsBody = io.micronaut.http.HttpMethod.permitsRequestBody(request.getMethod());
  NettyClientHttpRequest clientHttpRequest = (NettyClientHttpRequest) request;
  NettyRequestWriter requestWriter = buildNettyRequest(clientHttpRequest, requestURI, requestContentType, permitsBody);
  io.netty.handler.codec.http.HttpRequest nettyRequest = requestWriter.getNettyRequest();
  prepareHttpHeaders(requestURI, request, nettyRequest, permitsBody, true);
  return requestWriter;
}

代码示例来源:origin: micronaut-projects/micronaut-core

CorsOriginConfiguration config = optionalConfig.get();
HttpMethod requestMethod = request.getMethod();

代码示例来源:origin: micronaut-projects/micronaut-core

io.micronaut.http.HttpMethod method = request.getMethod();
for (HttpClientFilter filter : filters) {
  if (filter instanceof Toggleable && !((Toggleable) filter).isEnabled()) {

代码示例来源:origin: micronaut-projects/micronaut-core

private void handleStatusError(
    ChannelHandlerContext ctx,
    HttpRequest<?> request,
    NettyHttpRequest nettyHttpRequest,
    MutableHttpResponse<Object> defaultResponse,
    String message) {
  Optional<RouteMatch<Object>> statusRoute = router.route(defaultResponse.status());
  if (statusRoute.isPresent()) {
    RouteMatch<Object> routeMatch = statusRoute.get();
    handleRouteMatch(routeMatch, nettyHttpRequest, ctx);
  } else {
    if (HttpMethod.permitsRequestBody(request.getMethod())) {
      JsonError error = newError(request, message);
      defaultResponse.body(error);
    }
    AtomicReference<HttpRequest<?>> requestReference = new AtomicReference<>(request);
    Flowable<? extends MutableHttpResponse<?>> responsePublisher = filterPublisher(
        requestReference,
        Flowable.just(defaultResponse),
        ctx.channel().eventLoop()
    );
    subscribeToResponsePublisher(
        ctx,
        MediaType.APPLICATION_JSON_TYPE,
        requestReference,
        responsePublisher
    );
  }
}

代码示例来源:origin: micronaut-projects/micronaut-core

.orElse(MediaType.APPLICATION_JSON_TYPE);
boolean permitsBody = io.micronaut.http.HttpMethod.permitsRequestBody(finalRequest.getMethod());

代码示例来源:origin: micronaut-projects/micronaut-core

ConvertibleMultiValues<String> parameters = source.getParameters();
Argument<T> argument = context.getArgument();
HttpMethod httpMethod = source.getMethod();

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
protected void channelRead0(ChannelHandlerContext ctx, io.micronaut.http.HttpRequest<?> request) {
  ctx.channel().config().setAutoRead(false);
  io.micronaut.http.HttpMethod httpMethod = request.getMethod();
  String requestPath = request.getPath();

代码示例来源:origin: micronaut-projects/micronaut-core

ConvertibleMultiValues<String> parameters = source.getParameters();
Argument<T> argument = context.getArgument();
HttpMethod httpMethod = source.getMethod();
boolean permitsRequestBody = HttpMethod.permitsRequestBody(httpMethod);

代码示例来源:origin: micronaut-projects/micronaut-core

} else if (HttpMethod.requiresRequestBody(request.getMethod()) || argument.isAnnotationPresent(Nullable.class)) {
  value = (UnresolvedArgument) () -> {
    ArgumentBinder.BindingResult result = argumentBinder.bind(conversionContext, request);

代码示例来源:origin: io.micronaut/micronaut-http

@Override
public HttpMethod getMethod() {
  return getDelegate().getMethod();
}

代码示例来源:origin: micronaut-projects/micronaut-spring

@Override
public String getMethodValue() {
  return request.getMethod().name();
}

代码示例来源:origin: micronaut-projects/micronaut-spring

@Override
  public BindingResult<HttpMethod> bind(ArgumentConversionContext<HttpMethod> context, HttpRequest<?> source) {
    return () -> Optional.of(HttpMethod.valueOf(source.getMethod().name()));
  }
}

代码示例来源:origin: io.micronaut/http-server

/**
   * @param request The {@link HttpRequest} object
   * @return Return whether this request is a pre-flight request
   */
  static boolean isPreflightRequest(HttpRequest request) {
    HttpHeaders headers = request.getHeaders();
    Optional<String> origin = headers.getOrigin();
    return origin.isPresent() && headers.contains(ACCESS_CONTROL_REQUEST_METHOD) && HttpMethod.OPTIONS == request.getMethod();
  }
}

代码示例来源:origin: io.micronaut/http-client

private void traceRequest(io.micronaut.http.HttpRequest<?> request, io.netty.handler.codec.http.HttpRequest nettyRequest) {
  HttpHeaders headers = nettyRequest.headers();
  traceHeaders(headers);
  if (io.micronaut.http.HttpMethod.permitsRequestBody(request.getMethod()) && request.getBody().isPresent() && nettyRequest instanceof FullHttpRequest) {
    FullHttpRequest fullHttpRequest = (FullHttpRequest) nettyRequest;
    ByteBuf content = fullHttpRequest.content();
    if (log.isTraceEnabled()) {
      traceBody("Request", content);
    }
  }
}

代码示例来源:origin: io.micronaut/micronaut-http-client

private void traceRequest(io.micronaut.http.HttpRequest<?> request, io.netty.handler.codec.http.HttpRequest nettyRequest) {
  HttpHeaders headers = nettyRequest.headers();
  traceHeaders(headers);
  if (io.micronaut.http.HttpMethod.permitsRequestBody(request.getMethod()) && request.getBody().isPresent() && nettyRequest instanceof FullHttpRequest) {
    FullHttpRequest fullHttpRequest = (FullHttpRequest) nettyRequest;
    ByteBuf content = fullHttpRequest.content();
    if (log.isTraceEnabled()) {
      traceBody("Request", content);
    }
  }
}

代码示例来源:origin: io.micronaut/micronaut-http-client

private <I> NettyRequestWriter prepareRequest(io.micronaut.http.HttpRequest<I> request, URI requestURI) throws HttpPostRequestEncoder.ErrorDataEncoderException {
  MediaType requestContentType = request
      .getContentType()
      .orElse(MediaType.APPLICATION_JSON_TYPE);
  boolean permitsBody = io.micronaut.http.HttpMethod.permitsRequestBody(request.getMethod());
  NettyClientHttpRequest clientHttpRequest = (NettyClientHttpRequest) request;
  NettyRequestWriter requestWriter = buildNettyRequest(clientHttpRequest, requestURI, requestContentType, permitsBody);
  io.netty.handler.codec.http.HttpRequest nettyRequest = requestWriter.getNettyRequest();
  prepareHttpHeaders(requestURI, request, nettyRequest, permitsBody, true);
  return requestWriter;
}

代码示例来源:origin: io.micronaut/http-client

private <I> NettyRequestWriter prepareRequest(io.micronaut.http.HttpRequest<I> request, URI requestURI) throws HttpPostRequestEncoder.ErrorDataEncoderException {
  MediaType requestContentType = request
      .getContentType()
      .orElse(MediaType.APPLICATION_JSON_TYPE);
  boolean permitsBody = io.micronaut.http.HttpMethod.permitsRequestBody(request.getMethod());
  NettyClientHttpRequest clientHttpRequest = (NettyClientHttpRequest) request;
  NettyRequestWriter requestWriter = buildNettyRequest(clientHttpRequest, requestURI, requestContentType, permitsBody);
  io.netty.handler.codec.http.HttpRequest nettyRequest = requestWriter.getNettyRequest();
  prepareHttpHeaders(requestURI, request, nettyRequest, permitsBody, true);
  return requestWriter;
}

相关文章