Interface PathBinding
-
public interface PathBinding
A path binding represents some kind of "match" on the path of a request.- See Also:
PathBinder
-
-
Field Summary
Fields Modifier and Type Field Description static com.google.common.reflect.TypeToken<PathBinding>
TYPE
A type token for this type.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PathTokens
getAllTokens()
Similar togetTokens()
except that tokens of all parent bindings are included.String
getBoundTo()
The path of the request path that was bound to.String
getDescription()
Describes the kind of path that this binder binds to.String
getPastBinding()
The section of the path that is "past" where the binding bound to.PathTokens
getTokens()
Any tokens that the binding has extracted from the path.
-
-
-
Field Detail
-
TYPE
static final com.google.common.reflect.TypeToken<PathBinding> TYPE
A type token for this type.- Since:
- 1.1
-
-
Method Detail
-
getBoundTo
String getBoundTo()
The path of the request path that was bound to.Some bindings are "prefix" bindings, in which case they will not have bound to the whole path. The bound path is always absolute.
If a prefix binder for path "a/b/c" created a binding for path "a/b/c/d/e", the "bound to" value would be "a/b/c".
- Returns:
- The path of the request path that was bound to.
-
getPastBinding
String getPastBinding()
The section of the path that is "past" where the binding bound to.Strict bindings may bind to an exact path, therefore there is nothing "past" what they bind to.
If a prefix binder for path "a/b/c" created a binding for path "a/b/c/d/e", the "past binding" value would be "d/e".
- Returns:
- The part of the path bound to that is past where the binding bound to. May be an empty string if the exact path was bound to.
-
getDescription
String getDescription()
Describes the kind of path that this binder binds to.import ratpack.core.path.PathBinding; import ratpack.test.embed.EmbeddedApp; import static org.junit.jupiter.api.Assertions.assertEquals; public class Example { public static void main(String... args) throws Exception { EmbeddedApp.fromHandlers(c -> c .prefix(":foo/:bar?", c1 -> c1 .get("baz", ctx -> ctx.render(ctx.get(PathBinding.class).getDescription())) ) ).test(httpClient -> { assertEquals(":foo/:bar?/baz", httpClient.getText("/a/b/baz")); assertEquals(":foo/:bar?/baz", httpClient.getText("/c/d/baz")); }); } }
The spec is effectively the cumulative pattern strings used to define what to bind to.
- Returns:
- the kind of path that this binder binds to
- Since:
- 1.4
-
getTokens
PathTokens getTokens()
Any tokens that the binding has extracted from the path.The definition of how tokens are extracted is implementation specific. Except that tokens are never extracted from the query string, only the path.
The returned map is ordered. The order of the map entries denotes the order in which the tokens were extracted.
- Returns:
- Any tokens extracted by the binding.
- See Also:
getAllTokens()
-
getAllTokens
PathTokens getAllTokens()
Similar togetTokens()
except that tokens of all parent bindings are included.If a parent binding extracts a token with the same name as this binding, the token from this binding will supersede the value from the parent.
- Returns:
- All tokens extracted from the path by this binding and its parents.
-
-