Struct url_builder::URLBuilder
source · pub struct URLBuilder { /* private fields */ }
Implementations§
source§impl URLBuilder
impl URLBuilder
sourcepub fn new() -> URLBuilder
pub fn new() -> URLBuilder
Creates a new URLBuilder instance
Example
use url_builder::URLBuilder;
let mut ub = URLBuilder::new();
sourcepub fn build(self) -> String
pub fn build(self) -> String
Consumes the builder and returns a String, with the formatted url.
Example
use url_builder::URLBuilder;
let mut ub = URLBuilder::new();
ub.set_protocol("http")
.set_host("localhost")
.set_port(8000)
.add_route("query")
.add_param("first", "1")
.add_param("second", "2")
.add_param("third", "3");
let built_url = ub.build();
sourcepub fn add_param(&mut self, param: &str, value: &str) -> &mut Self
pub fn add_param(&mut self, param: &str, value: &str) -> &mut Self
Adds a parameter to the URL.
sourcepub fn set_protocol(&mut self, protocol: &str) -> &mut Self
pub fn set_protocol(&mut self, protocol: &str) -> &mut Self
Sets the protocol that the URL builder will use.
sourcepub fn set_host(&mut self, host: &str) -> &mut Self
pub fn set_host(&mut self, host: &str) -> &mut Self
Sets the protocol that the URL builder will use.
sourcepub fn set_port(&mut self, port: u16) -> &mut Self
pub fn set_port(&mut self, port: u16) -> &mut Self
Sets the port that the URL builder will use.