pub struct Request { /* private fields */ }Expand description
Capture the required and optional data for a call to the hcaptcha API
Implementations§
Source§impl Request
impl Request
Sourcepub fn new(secret: &str, captcha: Captcha) -> Result<Request, Error>
pub fn new(secret: &str, captcha: Captcha) -> Result<Request, Error>
Create a new Request
§Input
The Hcaptcha API has two mandatory parameters:
secret: The client’s secret key for authentication
captcha: Captcha (including response token)
§Output
Request is returned if the input strings are valid. Error is returned if the validation fails.
§Example
use hcaptcha_no_wasm::Request;
let secret = get_your_secret(); // your secret key
let captcha = get_captcha(); // captcha with response token
let request = Request::new(&secret, captcha)?;§Logging
If the tracing feature is enabled a debug level span is set for the method. The secret field will not be logged.
Sourcepub fn new_from_response(secret: &str, response: &str) -> Result<Request, Error>
pub fn new_from_response(secret: &str, response: &str) -> Result<Request, Error>
Create a new Request from only the response string
§Input
The Hcaptcha API has two mandatory parameters: secret: The client’s secret key for authentication response: The response code to validate
§Output
Request is returned if the inputs are valid. Error is returned if the validation fails.
§Example
use hcaptcha_no_wasm::Request;
let secret = get_your_secret(); // your secret key
let response = get_response(); // Hcaptcha client response
let request = Request::new_from_response(&secret, &response)?;§Logging
If the tracing feature is enabled a debug level span is set for the method. The secret field will not be logged.
Sourcepub fn set_remoteip(self, remoteip: &str) -> Result<Self, Error>
pub fn set_remoteip(self, remoteip: &str) -> Result<Self, Error>
Specify the optional ip address value
Update client IP address.
§Example
use hcaptcha_no_wasm::Request;
let secret = get_your_secret(); // your secret key
let response = get_response(); // user's response token
let remoteip = get_remoteip_address(); // user's ip address
let request = Request::new_from_response(&secret, &response)?
.set_remoteip(&remoteip)?;
#Logging
If the trace feature is enabled a debug level span is set for the
method.
The secret field is not logged.
Sourcepub fn set_sitekey(self, sitekey: &str) -> Result<Self, Error>
pub fn set_sitekey(self, sitekey: &str) -> Result<Self, Error>
Specify the optional sitekey value
Update the sitekey.
§Example
Create a new request and set the sitekey field in the request.
use hcaptcha_no_wasm::Request;
let secret = get_your_secret(); // your secret key
let captcha = get_captcha(); // captcha
let sitekey = get_your_sitekey(); // your site key
let request = Request::new(&secret, captcha)?
.set_sitekey(&sitekey);
#Logging
If the trace feature is enabled a debug level span is created for the
method.
The secret field is not logged.