Skip to content

Commit d378643

Browse files
committed
Update WebService.
1 parent 5732c22 commit d378643

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

kilo-server/src/main/java/org/httprpc/kilo/WebService.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,8 @@ public void init() throws ServletException {
873873

874874
var resource = root;
875875

876+
var n = 0;
877+
876878
var resourcePath = method.getAnnotation(ResourcePath.class);
877879

878880
if (resourcePath != null) {
@@ -886,9 +888,21 @@ public void init() throws ServletException {
886888
}
887889

888890
resource = resource.resources.computeIfAbsent(component, key -> new Resource());
891+
892+
if (component.equals(KEY_PLACEHOLDER)) {
893+
n++;
894+
}
889895
}
890896
}
891897

898+
if (verb == Verb.POST || verb == Verb.PUT) {
899+
n++;
900+
}
901+
902+
if (method.getParameterCount() < n) {
903+
throw new ServletException("Invalid parameter count.");
904+
}
905+
892906
resource.handlerLists.computeIfAbsent(verb, key -> new LinkedList<>()).add(method);
893907
}
894908

0 commit comments

Comments
 (0)