Skip to content

Commit

Permalink
remove wrapper in log and code formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-sharma7 committed Aug 16, 2023
1 parent 7b5cfdf commit 27e1c73
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class QuinoaDevProxyHandler implements Handler<RoutingContext> {
private final ClassLoader currentClassLoader;
private final QuinoaHandlerConfig config;

QuinoaDevProxyHandler(final QuinoaHandlerConfig config, final Vertx vertx, String host, int port, boolean websocket) {
QuinoaDevProxyHandler(final QuinoaHandlerConfig config, final Vertx vertx, String host, int port,
boolean websocket) {
this.host = host;
this.port = port;
this.client = WebClient.create(vertx);
Expand Down Expand Up @@ -85,7 +86,8 @@ private void handleHttpRequest(final RoutingContext ctx, final String resourcePa
final String uri = computeResourceURI(resourcePath, request);

// Workaround for issue https://github.com/quarkiverse/quarkus-quinoa/issues/91
// See https://www.npmjs.com/package/connect-history-api-fallback#htmlacceptheaders
// See
// https://www.npmjs.com/package/connect-history-api-fallback#htmlacceptheaders
// When no Accept header is provided, the historyApiFallback is disabled
headers.remove("Accept");
// Disable compression in the forwarded request
Expand Down Expand Up @@ -132,9 +134,7 @@ private void forwardError(AsyncResult<HttpResponse<Buffer>> event, int statusCod

private void forwardResponse(AsyncResult<HttpResponse<Buffer>> event, HttpServerRequest request, RoutingContext ctx,
String resourcePath) {
if (LOG.isDebugEnabled()) {
LOG.debugf("Quinoa is forwarding: '%s'", request.uri());
}
LOG.debugf("Quinoa is forwarding: '%s'", request.uri());
final HttpServerResponse response = ctx.response();
for (String header : HEADERS_TO_FORWARD) {
response.headers().add(header, event.result().headers().getAll(header));
Expand Down
13 changes: 7 additions & 6 deletions runtime/src/main/java/io/quarkiverse/quinoa/QuinoaRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,25 @@ public Handler<RoutingContext> quinoaHandler(final QuinoaHandlerConfig handlerCo
static String resolvePath(RoutingContext ctx) {
return (ctx.mountPoint() == null) ? ctx.normalizedPath()
: ctx.normalizedPath().substring(
// let's be extra careful here in case Vert.x normalizes the mount points at some point
// let's be extra careful here in case Vert.x normalizes the mount points at
// some point
ctx.mountPoint().endsWith("/") ? ctx.mountPoint().length() - 1 : ctx.mountPoint().length());
}

static boolean isIgnored(final String path, final List<String> ignoredPathPrefixes) {
if (ignoredPathPrefixes.stream().anyMatch(path::startsWith)) {
if (LOG.isDebugEnabled()) {
LOG.debugf("Quinoa is ignoring path (quarkus.quinoa.ignored-path-prefixes): " + path);
}
LOG.debugf("Quinoa is ignoring path (quarkus.quinoa.ignored-path-prefixes): " + path);
return true;
}
return false;
}

static void compressIfNeeded(QuinoaHandlerConfig config, RoutingContext ctx, String path) {
if (config.enableCompression && isCompressed(config, path)) {
// VertxHttpRecorder is adding "Content-Encoding: identity" to all requests if compression is enabled.
// Handlers can remove the "Content-Encoding: identity" header to enable compression.
// VertxHttpRecorder is adding "Content-Encoding: identity" to all requests if
// compression is enabled.
// Handlers can remove the "Content-Encoding: identity" header to enable
// compression.
ctx.response().headers().remove(HttpHeaders.CONTENT_ENCODING);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public void handle(RoutingContext ctx) {
}
String path = resolvePath(ctx);
if (!Objects.equals(path, "/") && !isIgnored(path, config.ignoredPathPrefixes)) {
if (LOG.isDebugEnabled()) {
LOG.debugf("Quinoa is re-routing SPA request '%s' to '/'", ctx.normalizedPath());
}
LOG.debugf("Quinoa is re-routing SPA request '%s' to '/'", ctx.normalizedPath());
ctx.reroute(ctx.mountPoint() != null ? ctx.mountPoint() : "/");
} else {
next(currentClassLoader, ctx);
Expand Down

0 comments on commit 27e1c73

Please sign in to comment.