There should be an uri::Builder
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 378
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 5
Description
Right now the burden of correct percent encoding is entirely on the user. This is completely unnecessary. Only accepting string URI also forces users to concatenate strings to construct an URI, which is bad and inefficient practice that leads to bugs.
Examples
Entirely segmented
Uri::builder()
.https() // In mio_httpc I have both https() and set_https(true).
.host("www.example.com")
.auth("user name", "my password")
.port(12345)
.path_segm("a/")
.path_segm("b")
.query("spaced key", "123")
.query("key", "<>")
Only partly segmented because schemes, hosts and optional ports are not a percent encoding problem and often stored as a fixed string on a client.
Uri::builder()
.base("https://www.example.com:8080")?
.path_segm("a/")
.path_segm("b")
.query("spaced key", "123")
.query("key", "<>")
Query and path segments could also be slices.
Uri::builder()
.base("https://www.example.com:8080")?
.path(&["a", "b", "c d"])
.query_pairs(&[("spaced key", "123"),("another","key")])
(edit by Sean)
To track the progress, here's what's done and needs to be done:
- Introduce
http::uri::Builder -
Builder::scheme() -
Builder::authority() -
Builder::host() -
Builder::port() -
Builder::path_and_query() - `Builder::path()
-
Builder::query()
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing http::uri::Builder implementation and its completed methods: scheme(), authority(), and path_and_query(). Use the checklist as the scope for the remaining host(), port(), path(), and query() work; done means those builder operations support the URI construction shown in the examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100