Skip to content

Undocumented stateful route behaviour #2193

@Madoshakalaka

Description

@Madoshakalaka

This is about:

  • A typo
  • Innaccurate/misleading documentation (e.g. technically incorrect advice)
  • Undocumented code
  • Outdated documentation
  • Other

Problem

Undocumented behavior: the router will try to redirect to the not found route when the deserialization fails:

#[derive(Clone, Routable, PartialEq)]
enum Route {
    #[at("/news/:id")]
    News{id: u8},
    #[not_found]
    #[at("/404")]
    NotFound,
}

News accepts an u8, but when the id goes over 255, the router redirects to the not found route.

router-path-matching-not-found

The behavior is vaguely mentioned here

/// When a route can't be matched, it looks for the route with `not_found` attribute.

If this is intended behavior, It needs to be documented.
The comment might also need to be more specific:

-  When a route can't be matched, it looks for the route with `not_found` attribute.
+ When a route can't be matched, including when the path is matched but the deserialization fails, it looks for the route with `not_found` attribute. 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions