Skip to content

Commit

Permalink
added fix for jax-rs regex paths no longer working (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
xgp authored Dec 11, 2023
1 parent 0e10723 commit 7cab573
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
42 changes: 42 additions & 0 deletions ext/main/java/io/phasetwo/portal/PortalResourceProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Optional;
import java.util.Properties;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import lombok.extern.jbosslog.JBossLog;
import org.keycloak.forms.login.LoginFormsProvider;
Expand Down Expand Up @@ -100,6 +101,47 @@ public Response preflight() {
return Cors.add(request, Response.ok()).auth().allowedMethods(METHODS).preflight().build();
}

/**
* something is seriously wrong since resteasy reactive upgrade. catch-all and regex paths no
* longer work from annotations. This is a hack to get v23 working in the meantime.
*/
@GET
@Path("{path:.+}")
public Response router(@PathParam("path") String path) throws Exception {
UriInfo uriInfo = session.getContext().getUri();
log.debugf("param path %s", path);
log.debugf("absolutePath %s", uriInfo.getAbsolutePath());
log.debugf("path %s", uriInfo.getPath());
log.debugf("baseUri %s", uriInfo.getBaseUri());
log.debugf("segments %s", uriInfo.getPathSegments());
log.debugf("requestUri %s", uriInfo.getRequestUri());

if (path == null || "".equals(path) || "/".equals(path)) return portal();
if (path.startsWith("/")) {
path = path.substring(1);
}

// staticResources
if (Pattern.matches("^(asset-manifest|logo|manifest|static|locales|favicon).*", path)) {
Response response = staticResources(path);
if (response != null) {
log.debugf("returning response %d for path %s", response.getStatus(), path);
return response;
}
}

// forward
if (Pattern.matches("^(profile|organizations).*", path)) {
Response response = forward();
if (response != null) {
log.debugf("forwarding response %d for path %s", response.getStatus(), path);
return response;
}
}

return portal();
}

@GET
@Path("{path: ^(profile|organizations).*}")
@Produces(MediaType.TEXT_HTML)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.14.2</version>
<version>1.15.0</version>
<executions>
<execution>
<id>setup-node-and-yarn</id>
Expand Down

0 comments on commit 7cab573

Please sign in to comment.