2 releases

0.1.1 Feb 28, 2023
0.1.0 Dec 19, 2022

#1495 in Web programming

Download history 2324/week @ 2024-07-25 2259/week @ 2024-08-01 2329/week @ 2024-08-08 2643/week @ 2024-08-15 2501/week @ 2024-08-22 1190/week @ 2024-08-29 619/week @ 2024-09-05 520/week @ 2024-09-12 529/week @ 2024-09-19 463/week @ 2024-09-26 1073/week @ 2024-10-03 2388/week @ 2024-10-10 3009/week @ 2024-10-17 2671/week @ 2024-10-24 2711/week @ 2024-10-31 2415/week @ 2024-11-07

11,468 downloads per month
Used in 8 crates (5 directly)

MIT/Apache

9KB
175 lines

url-builder-rs

A simple URL builder with no dependencies, useful for a drop-in way to build URLs in a safe way no matter the protocol. See docs.rs.

Example

use url_builder::URLBuilder;

let mut ub = URLBuilder::new();
ub.set_protocol("http")
    .set_host("localhost")
    .set_port(8000)
    .add_param("first", "1")
    .add_param("second", "2")
    .add_param("third", "3");

println!("{}", ub.build());

lib.rs:

URLBuilder

An easy-to-use crate to construct URLs for the Rust Programming language

You can use this to build up context for a url over the course of execution and then call the .build() method to generate the final url.

The mutating functions allow you to chain them to each other.

Example

The following code will create a url similar to http://localhost:8000?first=1&second=2&third=3 The order of the query parameters is indeterminate as the parameters are internally stored in std::collections::HashMap.

use url_builder::URLBuilder;

let mut ub = URLBuilder::new();

ub.set_protocol("http")
    .set_host("localhost")
    .set_port(8000)
    .add_param("first", "1")
    .add_param("second", "2")
    .add_param("third", "3");

println!("{}", ub.build());

No runtime deps