Skip to content

Commit

Permalink
Handle slash in subject name.
Browse files Browse the repository at this point in the history
  • Loading branch information
gklijs committed Oct 13, 2024
1 parent efdcebd commit 14b719d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/schema_registry_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,26 @@ pub enum SrCall<'a> {
pub(crate) fn url_for_call(call: &SrCall, base_url: &str) -> String {
match call {
SrCall::GetById(id) => format!("{}/schemas/ids/{}?deleted=true", base_url, id),
SrCall::GetLatest(subject) => format!("{}/subjects/{}/versions/latest", base_url, subject),
SrCall::GetLatest(subject) => {
// Use escape sequences instead of slashes in the subject
format!("{}/subjects/{}/versions/latest", base_url, subject.replace("/", "%2F"))
}
SrCall::GetBySubjectAndVersion(subject, version) => {
format!("{}/subjects/{}/versions/{}", base_url, subject, version)
// Use escape sequences instead of slashes in the subject
format!("{}/subjects/{}/versions/{}", base_url, subject.replace("/", "%2F"), version)
}
SrCall::PostNew(subject, _) => {
// Use escape sequences instead of slashes in the subject
format!("{}/subjects/{}/versions", base_url, subject.replace("/", "%2F"))
}
SrCall::PostNew(subject, _) => format!("{}/subjects/{}/versions", base_url, subject),
SrCall::PostForVersion(subject, _) => {
format!("{}/subjects/{}?deleted=false", base_url, subject)
// Use escape sequences instead of slashes in the subject
format!("{}/subjects/{}?deleted=false", base_url, subject.replace("/", "%2F"))
}
}
}


/// Creates payload that can be included as a key or value on a kafka record
pub fn get_payload(id: u32, encoded_bytes: Vec<u8>) -> Vec<u8> {
let mut payload = vec![0u8];
Expand Down

0 comments on commit 14b719d

Please sign in to comment.