Skip to content

Commit 7ef4f87

Browse files
committed
Context: remove pathString() fix #1646
1 parent e5188d3 commit 7ef4f87

13 files changed

Lines changed: 36 additions & 65 deletions

File tree

docs/asciidoc/context.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Path parameter are part of the `URI`. To define a path variable you need to use
134134
----
135135
{
136136
get("/{name}", ctx -> {
137-
String pathString = ctx.getRequestPath(); // <1>
137+
String pathString = ctx.getRequestPath(); // <1>
138138
139139
Value path = ctx.path(); // <2>
140140
@@ -152,7 +152,7 @@ Path parameter are part of the `URI`. To define a path variable you need to use
152152
----
153153
{
154154
get("/{name}") {
155-
val pathString = ctx.getRequestPath() // <1>
155+
val pathString = ctx.getRequestPath() // <1>
156156
157157
val path = ctx.path() // <2>
158158

docs/asciidoc/routing.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,13 +1184,13 @@ Composition is available through the javadoc:Router[use, io.jooby.Router] operat
11841184
----
11851185
public class Foo extends Jooby {
11861186
{
1187-
get("/foo", Context::pathString);
1187+
get("/foo", Context::getRequestPath);
11881188
}
11891189
}
11901190
11911191
public class Bar extends Jooby {
11921192
{
1193-
get("/bar", Context::pathString);
1193+
get("/bar", Context::getRequestPath);
11941194
}
11951195
}
11961196
@@ -1200,7 +1200,7 @@ public class App extends Jooby {
12001200
12011201
use(new Bar()); // <2>
12021202
1203-
get("/app", Context::pathString); // <3>
1203+
get("/app", Context::getRequestPath); // <3>
12041204
}
12051205
}
12061206
----
@@ -1241,7 +1241,7 @@ class App: Kooby({
12411241
----
12421242
public class Foo extends Jooby {
12431243
{
1244-
get("/foo", Context::pathString);
1244+
get("/foo", Context::getRequestPath);
12451245
}
12461246
}
12471247

jooby/src/main/java/io/jooby/Context.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,6 @@ public interface Context extends Registry {
213213
return getRouter().getContextPath();
214214
}
215215

216-
/**
217-
* Request path without decoding (a.k.a raw Path) without query string.
218-
*
219-
* @return Request path without decoding (a.k.a raw Path) without query string.
220-
* @deprecated Use {{@link #getRequestPath()}}.
221-
*/
222-
@Deprecated
223-
@Nonnull String pathString();
224-
225216
/**
226217
* Request path without decoding (a.k.a raw Path) without query string.
227218
*

jooby/src/main/java/io/jooby/DefaultContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public interface DefaultContext extends Context {
6464
}
6565

6666
@Override default boolean matches(String pattern) {
67-
return getRouter().match(pattern, pathString());
67+
return getRouter().match(pattern, getRequestPath());
6868
}
6969

7070
/**

jooby/src/main/java/io/jooby/ForwardingContext.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ public ForwardingContext(@Nonnull Context context) {
121121
return ctx.setRoute(route);
122122
}
123123

124-
@Override @Nonnull public String pathString() {
125-
return ctx.getRequestPath();
126-
}
127-
128124
@Nonnull @Override public String getRequestPath() {
129125
return ctx.getRequestPath();
130126
}

jooby/src/main/java/io/jooby/WebVariables.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Template engine will be able to access to the following attributes:
2323
*
2424
* - contextPath. Empty when context path is set to <code>/</code> or actual context path.
25-
* - path. Current request path, as defined by {@link Context#pathString()}.
25+
* - path. Current request path, as defined by {@link Context#getRequestPath()}.
2626
* - user. Current user (if any) as defined by {@link Context#getUser()}.
2727
*
2828
* @author edgar

jooby/src/test/java/io/jooby/internal/ReturnTypeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void literals() {
8383
public void methodInvocation() {
8484
assertType(String.class, ctx -> ctx.getRequestPath());
8585

86-
assertType(String.class, Context::pathString);
86+
assertType(String.class, Context::getRequestPath);
8787
}
8888

8989
@Test

modules/jooby-jetty/src/main/java/io/jooby/internal/jetty/JettyContext.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ public JettyContext(Request request, Router router, int bufferSize, long maxRequ
159159
return this;
160160
}
161161

162-
@Nonnull @Override public String pathString() {
163-
return getRequestPath();
164-
}
165-
166162
@Nonnull @Override public String getRequestPath() {
167163
return requestPath;
168164
}
@@ -570,9 +566,9 @@ void complete(Throwable x) {
570566
Logger log = router.getLog();
571567
if (x != null) {
572568
if (Server.connectionLost(x)) {
573-
log.debug("exception found while sending response {} {}", getMethod(), pathString(), x);
569+
log.debug("exception found while sending response {} {}", getMethod(), getRequestPath(), x);
574570
} else {
575-
log.error("exception found while sending response {} {}", getMethod(), pathString(), x);
571+
log.error("exception found while sending response {} {}", getMethod(), getRequestPath(), x);
576572
}
577573
}
578574
} finally {

modules/jooby-netty/src/main/java/io/jooby/internal/netty/NettyContext.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,6 @@ public NettyContext(ChannelHandlerContext ctx, HttpRequest req, Router router, S
171171
return this;
172172
}
173173

174-
@Nonnull @Override public final String pathString() {
175-
return path;
176-
}
177-
178174
@Nonnull @Override public String getRequestPath() {
179175
return path;
180176
}
@@ -698,11 +694,11 @@ void destroy(Throwable cause) {
698694
if (cause != null) {
699695
if (Server.connectionLost(cause)) {
700696
router.getLog()
701-
.debug("exception found while sending response {} {}", getMethod(), pathString(),
697+
.debug("exception found while sending response {} {}", getMethod(), getRequestPath(),
702698
cause);
703699
} else {
704700
router.getLog()
705-
.error("exception found while sending response {} {}", getMethod(), pathString(),
701+
.error("exception found while sending response {} {}", getMethod(), getRequestPath(),
706702
cause);
707703
}
708704
}
@@ -798,6 +794,6 @@ private void prepareChunked() {
798794
}
799795

800796
@Override public String toString() {
801-
return getMethod() + " " + pathString();
797+
return getMethod() + " " + getRequestPath();
802798
}
803799
}

modules/jooby-test/src/main/java/io/jooby/MockContext.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,6 @@ public MockContext setFlashMap(@Nonnull FlashMap flashMap) {
199199
return this;
200200
}
201201

202-
@Nonnull @Override public String pathString() {
203-
return requestPath;
204-
}
205-
206202
@Nonnull @Override public String getRequestPath() {
207203
return requestPath;
208204
}
@@ -213,7 +209,7 @@ public MockContext setFlashMap(@Nonnull FlashMap flashMap) {
213209
* @param pathString Path string.
214210
* @return This context.
215211
*/
216-
public @Nonnull MockContext setRequestPath(@Nonnull String pathString) {
212+
@Override public @Nonnull MockContext setRequestPath(@Nonnull String pathString) {
217213
int q = pathString.indexOf("?");
218214
if (q > 0) {
219215
this.requestPath = pathString.substring(0, q);

0 commit comments

Comments
 (0)