Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider using http::Uri dependency instead of url::Url #459

Closed
DanGould opened this issue Jan 3, 2025 Discussed in #288 · 1 comment
Closed

consider using http::Uri dependency instead of url::Url #459

DanGould opened this issue Jan 3, 2025 Discussed in #288 · 1 comment
Milestone

Comments

@DanGould
Copy link
Contributor

DanGould commented Jan 3, 2025

Discussed in https://github.com/orgs/payjoin/discussions/288

Originally posted by DanGould June 13, 2024
The payjoin protocol deals with HTTP messages, not ftp/unix/data protocols and so using the lighter weight http::Uri type may be more appropriate than url::Url and give validation control over exactly the types of URLs that we need to deal with.

The original bip78 crate from Kixunil used url so we just kept with it without thinking through this dependency https://github.com/Kixunil/payjoin/blob/master/bip78/Cargo.toml

@DanGould
Copy link
Contributor Author

DanGould commented Jan 27, 2025

The things url::Url provides that http::Uri is missing include the following:

  1. query parameter mapping to query_pairs
  2. returning URL fragment identifier
  3. Serializing URLs with serde

While these aren't HUGE features for us to make and maintain, Having the experience of doing some tricky parsing for BIP 77 and making mistakes requiring rewrites, I'd rather depend on more vetted work unless an implementer downstream requested explicit removal of this dependency in order for us to limit our maintenance burden. bhttp also already depends on url, so removing the dependency from the default v2 feature set would require a bhttp refactor to remove the url crate as well.

Instead of removing the dependency, I'd still like to remove url::Url from our public API. I like how reqwest::IntoUrl works which does URL validation on strings as arguments into functions like post. Then we can reveal our own public API error variants that also do not explicitly depend on url::Url, and only depend on it internally.

This removes the burden of URL parsing from the downstream implementer and puts it into our core typestate machines.

I'm going to close this issue and open a new on on the IntoUrl approach. (new issue: #513)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

1 participant