Skip to content

Commit 92cbe68

Browse files
committed
feature: support multiple application on single server #3645
- javadoc for Context.Selector
1 parent 9777eb9 commit 92cbe68

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,27 @@
4646
*/
4747
public interface Context extends Registry {
4848

49+
/** Select an application base on context path prefix matching a provided path. */
4950
interface Selector {
51+
/**
52+
* Select an application base on context path prefix matching a provided path.
53+
*
54+
* @param applications List of applications.
55+
* @param path Path to match.
56+
* @return Best match application.
57+
*/
5058
Jooby select(List<Jooby> applications, String path);
5159

5260
static Selector create(List<Jooby> applications) {
5361
return applications.size() == 1 ? single() : multiple();
5462
}
5563

64+
/**
65+
* Select an application the best match a given path. If none matches it returns the application
66+
* that has no context path <code>/</code> or the first of the list.
67+
*
68+
* @return Best match application.
69+
*/
5670
static Selector multiple() {
5771
return (applications, path) -> {
5872
var defaultApp = applications.get(0);
@@ -68,13 +82,8 @@ static Selector multiple() {
6882
};
6983
}
7084

71-
static Selector single() {
72-
return new Selector() {
73-
@Override
74-
public Jooby select(List<Jooby> applications, String path) {
75-
return applications.get(0);
76-
}
77-
};
85+
private static Selector single() {
86+
return (applications, path) -> applications.get(0);
7887
}
7988
}
8089

0 commit comments

Comments
 (0)