SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
6.57k stars 461 forks source link

Incorrect Route Matching Behavior in Actix Example Code #2122

Closed ikka0426 closed 3 months ago

ikka0426 commented 4 months ago

Description

I discovered an issue with the route matching behavior in the example code located in the examples/actix_example directory. When accessing routes that do not match the specified patterns like /xxx, instead of returning a 404 Not Found page, the application returns an error message can not parse 'xxx' to a i32.

Steps to Reproduce

  1. Navigate to the examples/actix_example directory.
  2. Run cargo run to start the application.
  3. Access a route that does not match any specified patterns, for example, /xxx.
  4. Observe the application's response and note that it does not behave as expected.

Expected Behavior

I expect the application to handle routes that do not match any specified patterns appropriately, such as returning a 404 page.

Actual Behavior

Instead of returning a 404 page, the application returns an error message can not parse 'xxx' to a i32.

Reproduces How Often

This issue is reproducible every time.

Workarounds

The issue seems to be caused by /xxx matching the #[get("/{id}")] route in examples/actix_example/api/src/lib.rs. This leads to the execution of the async fn edit(data: web::Data<AppState>, id: web::Path<i32>) -> Result<HttpResponse, Error> handler function.

tyt2y3 commented 4 months ago

A PR would be appreciated