Add pattern syntax for optional trailing slash

Open
#3,281 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@deepto98 is already working on this.

Since May 13, 2024.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
api, backend

Research direction

Start with the linked discussion to understand the proposed route-pattern behavior and any unresolved design questions. Trace how route patterns are parsed and matched, then define completion as a pattern such as "/some/path/?" matching both slash variants without changing other routing behavior; add coverage for both request paths.

Written by the indexing model from the issue text.

Description

A-router A-web C-feature

I proposed this idea in https://github.com/actix/actix-web/discussions/3258#discussioncomment-8358174 to handle cases where trailing slashes are relevant. Basically, allow defining a route with a pattern like "/some/path/?" that matches both "/some/path" and "/some/path/". I also proposed to add a method to check whether the URI has a trailing slash, but that can also be done with request.uri().path().ends_with('/'), so idk whether we actually need this.

Dominant language
Rust
Stars
24.9k
Forks
2k
Avg merge
19h 9m
Merged PRs (30d)
61

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from actix/actix-web

All issues in actix/actix-web

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.