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

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

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

HttpRequest.getUri介绍

暂无

代码示例

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

@Override
public URI getRequestURI() {
  return request.getUri();
}

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

/**
 * @return Is the request an HTTPS request
 */
default boolean isSecure() {
  String scheme = getUri().getScheme();
  return scheme != null && scheme.equals("https");
}

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

/**
 * @return Get the path without any parameters
 */
default @Nonnull String getPath() {
  return getUri().getPath();
}

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

/**
 * @return Obtain the server address
 */
default @Nonnull InetSocketAddress getServerAddress() {
  String host = getUri().getHost();
  int port = getUri().getPort();
  return new InetSocketAddress(host != null ? host : "localhost", port > -1 ? port : 80);
}

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

/**
 * @return The server host name
 */
default @Nullable
String getServerName() {
  return getUri().getHost();
}

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

@Override
public URI getUri() {
  return getDelegate().getUri();
}

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

/**
   * Obtains the web socket URL.
   *
   *
   * @param ctx The context
   * @param req The request
   * @return The socket URL
   */
  protected String getWebSocketURL(ChannelHandlerContext ctx, HttpRequest req) {
    boolean isSecure = ctx.pipeline().get(SslHandler.class) != null;
    return (isSecure ? SCHEME_SECURE_WEBSOCKET : SCHEME_WEBSOCKET) + req.getHeaders().get(HttpHeaderNames.HOST) + req.getUri() ;
  }
}

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

/**
 * @param matcher A {@link OutgointRequestProcessorMatcher} implementation. Entity defining matching rules.
 * @param request The request
 * @return true if the request should be processed
 */
public boolean shouldProcessRequest(OutgointRequestProcessorMatcher matcher, HttpRequest<?> request) {
  Optional<String> serviceId = request.getAttribute(HttpAttributes.SERVICE_ID.toString(), String.class);
  String uri = request.getUri().toString();
  return shouldProcessRequest(matcher, serviceId.orElse(null), uri);
}

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

private JsonError newError(io.micronaut.http.HttpRequest<?> request, String message) {
  URI uri = request.getUri();
  return new JsonError(message)
      .link(Link.SELF, Link.of(uri));
}

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

@Override
  public Object handle(HttpRequest request, JsonProcessingException exception) {
    // TODO: Send JSON back with detailed error
    MutableHttpResponse<Object> response = HttpResponse.status(HttpStatus.BAD_REQUEST, "Invalid JSON");
    JsonError body = new JsonError("Invalid JSON: " + exception.getMessage());
    body.link(Link.SELF, Link.of(request.getUri()));
    response.body(body);

    return response;
  }
}

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

@Override
  public HttpResponse handle(HttpRequest request, UnsatisfiedRouteException exception) {
    if (LOG.isErrorEnabled()) {
      LOG.error("{} (Bad Request): {}", request, exception.getMessage());
    }
    JsonError error = new JsonError(exception.getMessage());
    error.path('/' + exception.getArgument().getName());
    error.link(Link.SELF, Link.of(request.getUri()));
    return HttpResponse.badRequest(error);
  }
}

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

@Override
  public HttpResponse handle(HttpRequest request, DuplicateRouteException exception) {
    JsonError error = new JsonError(exception.getMessage());
    error.link(Link.SELF, Link.of(request.getUri()));
    return HttpResponse.badRequest(error);
  }
}

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

ChannelPool channelPool) throws HttpPostRequestEncoder.ErrorDataEncoderException {
io.micronaut.http.HttpRequest<I> finalRequest = requestWrapper.get();
URI requestURI = finalRequest.getUri();
MediaType requestContentType = finalRequest
    .getContentType()

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

@Override
  public HttpResponse handle(HttpRequest request, HttpStatusException exception) {

    Object body = exception.getBody()
      .orElseGet(() -> {
        JsonError error = new JsonError(exception.getMessage());
        error.link(Link.SELF, Link.of(request.getUri()));

        return error;
      });

    return HttpResponse
      .status(exception.getStatus())
      .body(body);
  }
}

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

@Override
  public HttpResponse handle(HttpRequest request, ContentLengthExceededException exception) {
    JsonError error = new JsonError(exception.getMessage());
    error.link(Link.SELF, Link.of(request.getUri()));

    return HttpResponse
      .status(HttpStatus.REQUEST_ENTITY_TOO_LARGE)
      .body(error);
  }
}

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

LOG.debug("No matching route found for URI {} and method {}", request.getUri(), httpMethod);
  if (!existingRouteConsumes.contains(contentType)) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Content type not allowed for URI {}, method {}, and content type {}", request.getUri(), httpMethod, contentType);
  .findAny(request.getUri().toString())
  .map(UriRouteMatch::getHttpMethod)
  .collect(Collectors.toSet());
  LOG.debug("Method not allowed for URI {} and method {}", request.getUri(), httpMethod);

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

/**
 * @param request The request
 * @param <I>     The input type
 * @return A {@link Publisher} with the resolved URI
 */
protected <I> Publisher<URI> resolveRequestURI(io.micronaut.http.HttpRequest<I> request) {
  URI requestURI = request.getUri();
  if (requestURI.getScheme() != null) {
    // if the request URI includes a scheme then it is fully qualified so use the direct server
    return Publishers.just(requestURI);
  } else {
    return Publishers.map(loadBalancer.select(getLoadBalancerDiscriminator()), server -> {
          Optional<String> authInfo = server.getMetadata().get(io.micronaut.http.HttpHeaders.AUTHORIZATION_INFO, String.class);
          if (request instanceof MutableHttpRequest) {
            if (authInfo.isPresent()) {
              ((MutableHttpRequest) request).getHeaders().auth(authInfo.get());
            }
          }
          return server.resolve(resolveRequestURI(requestURI));
        }
    );
  }
}

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

@Override
  public HttpResponse handle(HttpRequest request, UnsatisfiedArgumentException exception) {
    JsonError error = new JsonError(exception.getMessage());
    error.path('/' + exception.getArgument().getName());
    error.link(Link.SELF, Link.of(request.getUri()));

    return HttpResponse.badRequest(error);
  }
}

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

@Override
  public HttpResponse handle(HttpRequest request, ConversionErrorException exception) {
    JsonError error = new JsonError(exception.getMessage());
    error.path('/' + exception.getArgument().getName());
    error.link(Link.SELF, Link.of(request.getUri()));

    return HttpResponse.badRequest(error);
  }
}

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

/**
 * @return Is the request an HTTPS request
 */
default boolean isSecure() {
  String scheme = getUri().getScheme();
  return scheme != null && scheme.equals("https");
}

相关文章