Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit99e39e2

Browse files
committed
CRA Resource: check that at least one react application is registered
1 parente3e9314 commit99e39e2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎src/main/java/com/indoqa/boot/html/react/AbstractCreateReactAppResourceBase.java‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
importjava.util.Objects;
2525
importjavax.inject.Inject;
2626

27+
importcom.indoqa.boot.ApplicationInitializationException;
2728
importcom.indoqa.boot.html.builder.HtmlBuilder;
2829
importcom.indoqa.boot.html.react.AbstractCreateReactAppResourceBase.ResponseEnhancements.ResponseEnhancementsBuilder;
2930
importcom.indoqa.boot.html.resources.AbstractHtmlResourcesBase;
@@ -121,10 +122,13 @@ protected void html(String classPathLocation, String fileSystemLocation,
121122

122123
protectedvoidhtml(ReactApplicationsreactApplications) {
123124
Objects.requireNonNull(reactApplications,"ReactApplications must not be null.");
125+
if (reactApplications.isEmpty()) {
126+
thrownewApplicationInitializationException("At least one ReactApplication has to be provided.");
127+
}
124128
Spark.after((request,response) -> {
125129
ReactApplicationreactApplication =reactApplications.lookup(request,response);
126130
if (reactApplication ==null) {
127-
Spark.notFound("NoReactapplication available.");
131+
Spark.notFound("Any of the registeredReactapplications can answer this request.");
128132
return;
129133
}
130134

@@ -207,6 +211,10 @@ public void add(String classPathLocation, String fileSystemLocation, ResponseEnh
207211
this.apps.add(newReactApplication(staticHandler,indexHtmlBuilder,responseEnhancementsProvider,testReactApplication));
208212
}
209213

214+
privatebooleanisEmpty() {
215+
returnthis.apps.isEmpty();
216+
}
217+
210218
ReactApplicationlookup(Requestreq,Responseres) {
211219
for (ReactApplicationapp :this.apps) {
212220
if (app.testReactApplication.invoke(req,res)) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp