4 releases (2 breaking)

0.6.2 Aug 26, 2022
0.6.1 Aug 22, 2022
0.5.0 Aug 22, 2022
0.4.0 Aug 22, 2022

#352 in HTTP client

Download history 448/week @ 2023-11-30 1059/week @ 2023-12-07 450/week @ 2023-12-14 508/week @ 2023-12-21 133/week @ 2023-12-28 400/week @ 2024-01-04 441/week @ 2024-01-11 433/week @ 2024-01-18 352/week @ 2024-01-25 520/week @ 2024-02-01 469/week @ 2024-02-08 551/week @ 2024-02-15 269/week @ 2024-02-22 321/week @ 2024-02-29 1038/week @ 2024-03-07 685/week @ 2024-03-14

2,491 downloads per month

MIT license

9KB
171 lines

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.

lib.rs:

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.

Dependencies

~14KB