format-url

Crates.ioformat-url
lib.rsformat-url
version0.6.2
sourcesrc
created_at2022-08-22 13:47:13.544408
updated_at2022-08-26 07:23:33.713752
descriptionMake building URLs more ergonomic.
homepagehttps://github.com/alextes/format-url
repository
max_upload_size
id650388
size9,095
Alexander Tesfamichael (alextes)

documentation

README

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.
Commit count: 0

cargo fmt