Struct unftp_auth_rest::Builder
source · pub struct Builder { /* private fields */ }
Expand description
Used to build the RestAuthenticator
Implementations§
source§impl Builder
impl Builder
sourcepub fn new() -> Builder
pub fn new() -> Builder
Creates a new Builder
instance with default settings.
This method initializes a new builder that you can use to configure and
ultimately construct a RestAuthenticator
. Each setting has a default
value that can be customized through the builder’s methods.
For customization we have several methods:
The placeholder methods (E.g.: with_username_placeholder
) allow you to
configure placeholders for certain fields.
These placeholders, will be replaced by actual values (FTP username,
password, or the client’s source IP) when preparing requests.
You can use these placeholders in the templates supplied with_url
or
with_body
.
sourcepub fn with_username_placeholder(self, s: String) -> Self
pub fn with_username_placeholder(self, s: String) -> Self
Sets the placeholder for the FTP username.
This placeholder will be replaced with the actual FTP username in the fields where it’s used. Refer to the general placeholder concept above for more information.
Arguments
s
- AString
representing the placeholder for the FTP username.
Examples
let mut builder = Builder::new()
.with_username_placeholder("{USER}".to_string())
.with_body(r#"{"username":"{USER}","password":"{PASS}"}"#.to_string());
In the example above, {USER}
within the body template is replaced with the actual FTP username during request
preparation. If the placeholder configuration is not set, any {USER}
text would stay unreplaced in the request.
sourcepub fn with_password_placeholder(self, s: String) -> Self
pub fn with_password_placeholder(self, s: String) -> Self
Sets the placeholder for the FTP password.
This placeholder will be replaced with the actual FTP password in the fields where it’s used. Refer to the general placeholder concept above for more information.
Arguments
s
- AString
representing the placeholder for the FTP password.
Examples
let mut builder = Builder::new()
.with_password_placeholder("{PASS}".to_string())
.with_body(r#"{"username":"{USER}","password":"{PASS}"}"#.to_string());
In the example above, {PASS}
within the body template is replaced with the actual FTP password during request
preparation. If the placeholder configuration is not set, any {PASS}
text would stay unreplaced in the request.
sourcepub fn with_source_ip_placeholder(self, s: String) -> Self
pub fn with_source_ip_placeholder(self, s: String) -> Self
Sets the placeholder for the source IP of the FTP client.
This placeholder will be replaced with the actual source IP in the fields where it’s used. Refer to the general placeholder concept above for more information.
Arguments
s
- AString
representing the placeholder for the FTP client’s source IP.
Examples
let mut builder = Builder::new()
.with_source_ip_placeholder("{IP}".to_string())
.with_body(r#"{"username":"{USER}","password":"{PASS}", "source_ip":"{IP}"}"#.to_string());
In the example above, {IP}
within the body template is replaced with the actual source IP of the FTP client
during request preparation. If the placeholder configuration is not set, any {IP}
text would stay unreplaced
in the request.
sourcepub fn with_method(self, s: Method) -> Self
pub fn with_method(self, s: Method) -> Self
specify HTTP method
sourcepub fn with_body(self, s: String) -> Self
pub fn with_body(self, s: String) -> Self
specify HTTP body (ignored if does not apply for method)
sourcepub fn with_selector(self, s: String) -> Self
pub fn with_selector(self, s: String) -> Self
specify JSON selector to be used to extract the value from the response format is serde_json’s Value.pointer()
sourcepub fn with_regex(self, s: String) -> Self
pub fn with_regex(self, s: String) -> Self
specify the value the json selector’s result should match to