Skip to content

ensure_leading_slash and virtual hosting #3278

Answered by robjtede
yuzuquats asked this question in Q&A
Discussion options

You must be logged in to vote

The semantics of resource definitions is defined in detail over here: https://docs.rs/actix-web/4.5.1/actix_web/dev/struct.ResourceDef.html#pattern-format-and-matching-behavior

In particular:

This means that pattern string must either be empty or begin with a slash (/).

Therefore this behavior is intentional. The canonical way to avoid double slashes here is to use web::scope(""). This is also documented: https://docs.rs/actix-web/4.5.1/actix_web/struct.Scope.html#avoid-trailing-slashes.

Avoid using trailing slashes in the scope prefix (e.g., web::scope("/scope/")). It will almost certainly not have the expected behavior.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by robjtede
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants