Package ratpack.core.path
Interface PathBinder
-
public interface PathBinder
A path binder binds to a request path, extracting information from it.Path binders are the basis of path based “routing” in Ratpack, in conjunction with
Handlers.path(PathBinder, Handler)
. It is not common to use or create a path binder directly. Instead, methods such asChain.path(String, Handler)
create a binder from a string specification (usingparse(String, boolean)
).See the section on path binding as part of the Chain documentation for more information.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<PathBinding>
bind(PathBinding parentBinding)
Attempts to bind in the context of the given parent binding.static PathBinderBuilder
builder()
Creates a new path binder builder.static PathBinder
of(boolean exhaustive, Action<? super PathBinderBuilder> action)
Builds a path binder programmatically.static PathBinder
parse(String pathBindingSpec, boolean exhaustive)
Creates a path binder by parsing the given path binding specification.
-
-
-
Method Detail
-
bind
Optional<PathBinding> bind(PathBinding parentBinding)
Attempts to bind in the context of the given parent binding.A binder may use whatever strategy it desires to decider whether or not it wants to create a binding for the given path.
- Parameters:
parentBinding
- the parent binding- Returns:
- A binding if one could be created
-
parse
static PathBinder parse(String pathBindingSpec, boolean exhaustive)
Creates a path binder by parsing the given path binding specification.This method is used by methods such as
Chain.path(String, Class)
.See the section on path binding as part of the Chain documentation for the format of the string.
- Parameters:
pathBindingSpec
- the path binding specification.exhaustive
- whether the binder must match the entire unbound path (false for a prefix match)- Returns:
- a path binder constructed from the given path binding specification
-
of
static PathBinder of(boolean exhaustive, Action<? super PathBinderBuilder> action) throws Exception
Builds a path binder programmatically.- Parameters:
exhaustive
- whether the binder must match the entire unbound path (false for a prefix match)action
- the binder definition- Returns:
- a path binder
- Throws:
Exception
- any thrown byaction
-
builder
static PathBinderBuilder builder()
Creates a new path binder builder.- Returns:
- a new path binder builder
-
-