http-rs / http-rs/tide

Trailing slash

Open
#205 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
5.1k
Forks
329
PR merge metrics
No merged PRs in 30d

Description

When creating REST APIs with Tide, I expect code like the following will be fairly common:

```rust
let mut router = App::new();
router.at("/resource").nest(|router| {
router.at("/").get(async move |_| "Slash");
router.at("").get(async move |_| "Blank");
});
```

I don't think developers will type both routes often, but in the wild, it's highly likely that we'll find both techniques in use. Being a bit more explicit about how routes are added the looked up may be an option to prevent confusion going forward. When looking at the example, it isn't entirely clear how an incoming request would be handled.

As of this writing, Tide renders two different responses: `"Slash"` appears at the path with a trailing slash (`/resources/`), and `"Blank"` at `/resources`. Which leads to the following questions:

* Should Tide allow both a blank and slashed path in cases where the two are extremely similar?
* Does Tide require a configuration option to differentiate between matching paths with trailing slashes and empty paths? Do we enable this option by default?

I'm sure there are other considerations I haven't accounted for yet, and aware that this change could affect future work in `route-recognizer`. The above is merely a starting point for this discussion, and I'd like to hear what others think.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.