v0.2.11-pre.006
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-offchain-transport-lib/src/http_client.rs
|
||||
// version: 3
|
||||
// version: 4
|
||||
|
||||
//! Crate-wide hardened REST client used internally by off-chain capability adapters.
|
||||
|
||||
@@ -36,6 +36,22 @@ impl crate::HttpGetRequest {
|
||||
return Self::parse(url, false);
|
||||
}
|
||||
|
||||
/// Appends one validated non-secret path segment to a crate-owned official provider base URL.
|
||||
pub(crate) fn append_path_segment(&mut self, value: &str) -> ksp_core_lib::Result<()> {
|
||||
let segments_result = self.url.path_segments_mut();
|
||||
let mut segments = match segments_result {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(()) => {
|
||||
return std::result::Result::Err(
|
||||
ksp_core_lib::Error::new(crate::ERROR_CODE_HTTP_REQUEST_INVALID, "Off-chain provider URL cannot accept a path segment")
|
||||
.with_context("field", "provider_url_path"),
|
||||
);
|
||||
},
|
||||
};
|
||||
segments.push(value);
|
||||
return std::result::Result::Ok(());
|
||||
}
|
||||
|
||||
/// Appends one non-secret query pair using URL encoding.
|
||||
pub(crate) fn append_query_pair(&mut self, name: &'static str, value: &str) {
|
||||
self.url.query_pairs_mut().append_pair(name, value);
|
||||
|
||||
Reference in New Issue
Block a user