I decided to try how vert.x web uses regular expressions. In the documentation, I found the following:
You can also capture path parameters when using regular expressions, here's an example: Route route = router.routeWithRegex(".*foo"); // This regular expression matches paths that start with something like: // "/foo/bar" - where the "foo" is captured into param0 and the "bar" is captured into // param1 route.pathRegex("\\/([^\\/]+)\\/([^\\/]+)").handler(routingContext -> { String productType = routingContext.request().getParam("param0"); String productID = routingContext.request().getParam("param1"); // Do something with them... }); In the above example, if a request is made to path: /tools/drill123/ then the route will match and productType will receive the value tools and productID will receive the value drill123. Captures are denoted in regular expressions with capture groups (ie surrounding the capture with round brackets) The explanations of the developers are not completely clear, namely 2 methods:
routeWithRegex(".*foo") -что передается данному методу?часть адреса,общая для всех рутов?к примеру у нас есть руты foo/authentification/username/ foo / authentification / accountname / means the common part of the root-foo is transferred to this method?
further pathRegex("\\/([^\\/]+)\\/([^\\/]+)") -this method accepts a template that will match what the user enters after foo?
and after
String productType = routingContext.request().getParam("param0"); String productID = routingContext.request().getParam("param1"); in this case, if you use foo / authentification / username / then productType = authentification; productID = username;
I understand correctly? Because these methods do not work ... please tell me who understood what is happening in them.