tsukuyomi-rs / tsukuyomi

Asynchronous Web framework for Rust
https://tsukuyomi-rs.github.io/tsukuyomi
Apache License 2.0
84 stars 3 forks source link

Reconsider behaviors when the route is not matched #187

Closed ubnt-intrepid closed 5 years ago

ubnt-intrepid commented 5 years ago

It is unclear how to treat the scope information when the route matched to incoming request is not indeterminate, and it makes difficult to properly handle the error management in CORS, session management, etc. It is necessary to clarify the behavior for handling the recognize errors.

ubnt-intrepid commented 5 years ago

The case when the path is not recognized

In this case, the following two assumption are considered:

For example, consider the following situation:

app!()
  .mount(
    scope!("/foo")  // <-- (S1)
      .mount(scope!("/bar/baz"))  // <-- (S2)
      .mount(scope!("/bar/foo"))  // <-- (S3)
  )

When a request that has the path such as /foo/bar comes, it is obvious that its scope is either S1, S2 or S3, and it is intuitive that the error handler called at this time is the one registered in S1.

The case when the path is recognized but the method is incorrect

In this case, the scope identifier could be uniquely determined by assuming that the all routes that have the same path must be belong to the same scope.

ubnt-intrepid commented 5 years ago

The behavior when the route is undetermined has been fixed in #188. The recognizer will return a set of candidates of partially matching routes, and infers the scope identifier of the incoming URL based on its information.