Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit 19f674b

Browse files
committed
Shorthand for /**/*
1 parent a80219a commit 19f674b

6 files changed

Lines changed: 16 additions & 14 deletions

File tree

jooby-core/src/main/java/jooby/Jooby.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public class Jooby {
320320
}
321321

322322
public RouteDefinition use(final Filter filter) {
323-
return use("/**", filter);
323+
return use("*", filter);
324324
}
325325

326326
public RouteDefinition use(final String path, final Filter filter) {

jooby-core/src/main/java/jooby/Response.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import jooby.fn.ExSupplier;
1515

1616
import com.google.common.annotations.Beta;
17-
import com.sun.xml.internal.ws.client.ContentNegotiation;
1817

1918
/**
2019
* Give you access to the actual HTTP response. You can read/write headers and write HTTP body.
@@ -52,7 +51,7 @@ interface Formatter {
5251
*
5352
* @param mediaType A media type to test for.
5453
* @param supplier An object provider.
55-
* @return A {@link ContentNegotiation}.
54+
* @return The current {@link Formatter}.
5655
*/
5756
@Nonnull
5857
default Formatter when(final String mediaType, final ExSupplier<Object> supplier) {
@@ -64,7 +63,7 @@ default Formatter when(final String mediaType, final ExSupplier<Object> supplier
6463
*
6564
* @param mediaType A media type to test for.
6665
* @param provider An object provider.
67-
* @return A {@link ContentNegotiation}.
66+
* @return A {@link Formatter}.
6867
*/
6968
@Nonnull
7069
Formatter when(MediaType mediaType, ExSupplier<Object> supplier);

jooby-core/src/main/java/jooby/internal/RoutePattern.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ private static String normalize(final String pattern) {
108108
if (pattern.equals("/")) {
109109
return buffer.append(pattern).toString();
110110
}
111+
if (pattern.equals("*")) {
112+
return buffer.append("/**/*").toString();
113+
}
111114
String normalized = SLASH.matcher(pattern).replaceAll("/");
112115
if (!normalized.startsWith("/")) {
113116
buffer.append("/");

jooby-core/src/test/java/jooby/internal/RoutePathTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@ public void moreExpression() {
293293

294294
@Test
295295
public void normalizePath() {
296-
assertEquals("GET/foo", new RoutePattern("GET", "/foo//").pattern());
297-
assertEquals("GET/foo", new RoutePattern("GET", "foo//").pattern());
298-
assertEquals("GET/foo", new RoutePattern("GET", "foo").pattern());
299-
assertEquals("GET/foo", new RoutePattern("GET", "foo/").pattern());
300-
assertEquals("GET/foo/bar", new RoutePattern("GET", "/foo//bar").pattern());
296+
assertEquals("/foo", new RoutePattern("GET", "/foo//").pattern());
297+
assertEquals("/foo", new RoutePattern("GET", "foo//").pattern());
298+
assertEquals("/foo", new RoutePattern("GET", "foo").pattern());
299+
assertEquals("/foo", new RoutePattern("GET", "foo/").pattern());
300+
assertEquals("/foo/bar", new RoutePattern("GET", "/foo//bar").pattern());
301301
}
302302

303303
}

jooby-hibernate/src/main/java/jooby/HibernatePersistence.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void configure(final Mode mode, final Config config, final Binder binder)
8484
Multibinder<RouteDefinition> routes = Multibinder.newSetBinder(binder, RouteDefinition.class);
8585

8686
routes.addBinding()
87-
.toInstance(RouteDefinition.newRoute("*", "/**", readWriteTrx(key)).name("hibernate"));
87+
.toInstance(RouteDefinition.newRoute("*", "*", readWriteTrx(key)).name("hibernate"));
8888

8989
Multibinder.newSetBinder(binder, RequestModule.class).addBinding().toInstance((b) -> {
9090
EntityManager em = emf.createEntityManager();

jooby-tests/src/test/java/jooby/StackFeature.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ public static class Resource {
2424
/** The logging system. */
2525
private final Logger log = LoggerFactory.getLogger(getClass());
2626

27-
@Path("/**")
27+
@Path("*")
2828
@jooby.mvc.GET
2929
public void xHeader(final Response resp) {
3030
log.info("X");
3131
resp.header("X", "x");
3232
}
3333

34-
@Path("/**")
34+
@Path("*")
3535
@jooby.mvc.GET
3636
public void yHeader(final Response resp) {
3737
log.info("Y");
@@ -66,11 +66,11 @@ public String subpathfjs() throws Exception {
6666

6767
{
6868

69-
get("/**", (req, resp) -> {
69+
get("*", (req, resp) -> {
7070
log.info("X");
7171
resp.header("X", "x");
7272
});
73-
get("/**", (req, resp) -> {
73+
get("*", (req, resp) -> {
7474
log.info("Y");
7575
resp.header("Y", "y");
7676
});

0 commit comments

Comments
 (0)