Skip to content

Commit 09ae9fa

Browse files
committed
allow path operator to globally set route properties fix #925
1 parent 2c9c09b commit 09ae9fa

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,11 +907,11 @@ public Jooby(final String prefix) {
907907
}
908908

909909
@Override
910-
public Jooby path(String path, Runnable action) {
910+
public Route.Collection path(String path, Runnable action) {
911911
this.path = Route.normalize(path);
912-
action.run();
912+
Route.Collection collection = with(action);
913913
this.path = null;
914-
return this;
914+
return collection;
915915
}
916916

917917
@Override

jooby/src/main/java/org/jooby/Router.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static String decode(String path) {
264264
* @param action Router action.
265265
* @return This router.
266266
*/
267-
Router path(String path, Runnable action);
267+
Route.Collection path(String path, Runnable action);
268268

269269
/**
270270
* Import content from provide application (routes, parsers/renderers, start/stop callbacks, ...

modules/coverage-report/src/test/java/org/jooby/issues/Issue900.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ public class Issue900 extends ServerFeature {
1515

1616
@Test
1717
public void shouldNotEncodingPlusSign() throws Exception {
18-
int ch = '+';
19-
System.out.println(Integer.toHexString(ch));
2018
request().get("/900/a+b")
2119
.expect("a b");
2220
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.jooby.issues;
2+
3+
import org.jooby.test.ServerFeature;
4+
import org.junit.Test;
5+
6+
public class Issue925 extends ServerFeature {
7+
8+
{
9+
path("/925/api/some", () -> {
10+
get(req -> req.route().produces());
11+
post(req -> req.route().consumes());
12+
}).produces("json")
13+
.consumes("json");
14+
}
15+
16+
@Test
17+
public void pathOperatorWithRouteProperties() throws Exception {
18+
request().get("/925/api/some")
19+
.expect("[application/json]");
20+
request().post("/925/api/some")
21+
.expect("[application/json]");
22+
}
23+
24+
}

0 commit comments

Comments
 (0)