Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alextes/format-url
https://github.com/alextes/format-url
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/alextes/format-url
- Owner: alextes
- Created: 2022-05-16T19:26:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-06T08:38:28.000Z (over 1 year ago)
- Last Synced: 2025-01-01T10:17:51.724Z (6 days ago)
- Language: Rust
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# format-url
Format URLs for fetch requests using templates and substitution values.
## Usage
```
use format_url::FormatUrl;let url = FormatUrl::new("https://api.example.com/")
.with_path_template("/user/:name")
.with_substitutes(vec![("name", "alex")])
.with_query_params(vec![("active", "true")])
.format_url();assert_eq!(url, "https://api.example.com/user/alex?active=true");
```## Wishlist
- Support for lists and nested values. (serde_urlencoded -> serde_qs)
- Support receiving query params as any value serde_urlencoded or serde_qs can serialize.
- Support receiving path template substitutes as a (Hash)Map, perhaps even a struct with
matching fields.