Routing by exact path

route可以被设定为匹配特定的URI. 在这种情况下,它就可以指定路径的请求了.

在下面的例子中,handler会被路径为/some/path/的请求调用. 但是我们会忽略末尾斜杠,因此当路径为/some/path/some/path//该handler都会被调用.

  1. Route route = router.route().path("/some/path/");
  2. route.handler(routingContext -> {
  3. // This handler will be called for the following request paths:
  4. // `/some/path`
  5. // `/some/path/`
  6. // `/some/path//`
  7. //
  8. // but not:
  9. // `/some/path/subdir`
  10. });