Skip to content

Commit bbcf529

Browse files
committed
Extending routes fix #365
1 parent b0aaa6f commit bbcf529

3 files changed

Lines changed: 63 additions & 3 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package org.jooby.issues;
2+
3+
import org.jooby.mvc.GET;
4+
import org.jooby.mvc.Path;
5+
import org.jooby.test.ServerFeature;
6+
import org.junit.Test;
7+
8+
public class Issue365 extends ServerFeature {
9+
10+
public static class Base {
11+
12+
@GET
13+
public String list() {
14+
return "base.list";
15+
}
16+
17+
@GET
18+
@Path("/:id")
19+
public String findById(final String id) {
20+
return "base.findById";
21+
}
22+
23+
}
24+
25+
@Path("/api/users")
26+
public static class Users extends Base {
27+
28+
@Override
29+
@GET
30+
public String list() {
31+
return "users.list";
32+
}
33+
34+
@GET
35+
@Path("/q/:q")
36+
public String query(final String q) {
37+
return "users.query";
38+
}
39+
40+
}
41+
42+
{
43+
use(Users.class);
44+
}
45+
46+
@Test
47+
public void list() throws Exception {
48+
request()
49+
.get("/api/users/1")
50+
.expect("base.findById");
51+
52+
request()
53+
.get("/api/users")
54+
.expect("users.list");
55+
56+
request()
57+
.get("/api/users/q/q")
58+
.expect("users.query");
59+
}
60+
61+
}

jooby/src/main/java/org/jooby/Jooby.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3473,8 +3473,7 @@ private String configTree(final String[] sources, final int i) {
34733473
}
34743474

34753475
private static List<Object> normalize(final List<Object> services, final Env env,
3476-
final RouteMetadata classInfo,
3477-
final String prefix) {
3476+
final RouteMetadata classInfo, final String prefix) {
34783477
List<Object> result = new ArrayList<>();
34793478
List<Object> snapshot = services;
34803479
/** modules, routes, parsers, renderers and websockets */

jooby/src/main/java/org/jooby/internal/mvc/MvcRoutes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static List<Route.Definition> routes(final Env env, final RouteMetadata c
8282
String[] rootExcludes = excludes(routeClass, EMPTY);
8383

8484
Map<Method, List<Class<?>>> methods = new HashMap<>();
85-
for (Method method : routeClass.getDeclaredMethods()) {
85+
for (Method method : routeClass.getMethods()) {
8686
List<Class<?>> annotations = new ArrayList<>();
8787
for (Class annotationType : VERBS) {
8888
Annotation annotation = method.getAnnotation(annotationType);

0 commit comments

Comments
 (0)