Feature Proposal: Builder for Constructing New URL Instances from Parts
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 406
- PR merge metrics
- No merged PRs in 30d
Description
I work with databases; a use case I often have isn't parsing a URL, but rather constructing one from pieces -- provide my own host or IP address, set a scheme, add query params one at a time or many at once, etc etc. The current API starts from an assumption of parsing an existing URL from a string, then modifying it. I'd like to propose a wrapper for constructing a new URL.
Personally, I quite like a builder for this kind of thing. I'm imagining something a little like:
let maybe_url = UrlBuilder::new()
.with_scheme("postgresql")
.with_host("10.40.0.9")
.with_port(5432)
.with_subresource("application_db")
.build();
match maybe_url {
Ok(url) => printlin!("Got: {}", url), // -> Got: postgresql://10.40.0.9:5432/application_db
Err(e) => eprintln!("Url construction failed: {}", e),
}
Convenience methods for common patterns can be provided: with_https, for instance; an API like with_http_defaults could pre-set scheme and port.
I'm happy to contribute this if it sounds like a feature y'all would like to have!
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
No files, tests, or entry points are named in the issue. Start by reviewing the existing URL parsing and modification API, then clarify the builder's supported parts, validation behavior, and convenience methods with maintainers; done should mean an agreed scope and corresponding coverage for constructing URLs from parts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100