thruster-rs / Thruster

A fast, middleware based, web framework written in Rust
MIT License
1.06k stars 47 forks source link

bug: Fix subtree wildcard propagation #255

Closed trezm closed 12 months ago

trezm commented 12 months ago

Wildcards when using router were not getting propagated down through the added router tree when there were no nodes. This, in general, is an edge case, however when attempting to apply a method like OPTIONS for CORS handling, often a subtree will not have any explicit OPTIONS routes. Previously, when the call was made, the route tree would see a terminal node in the default root of the OPTIONS tree for the router, and would use the 404 middleware that nodes default to. Now, if a node is default (and therefore non-terminal) the tree structure looks to see if the node is terminal and, if not, attempts to apply any wildcards before passing back the default middleware.