Skip to content

Commit

Permalink
feat(inscription): add content_encoding field on api (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
joundy committed Mar 22, 2024
1 parent dbb87a4 commit 760e99e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub struct Inscription {
// ---- Ordzaar ----
pub inscription_sequence: u32,
pub delegate: Option<InscriptionId>,
pub content_encoding: Option<String>,
// ---- Ordzaar ----
}

Expand Down
6 changes: 6 additions & 0 deletions src/inscriptions/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ impl Inscription {
str::from_utf8(self.content_type.as_ref()?).ok()
}

// ---- Ordzaar ----
pub(crate) fn content_encoding_str(&self) -> Option<&str> {
str::from_utf8(self.content_encoding.as_ref()?).ok()
}
// ---- Ordzaar ----

pub(crate) fn content_encoding(&self) -> Option<HeaderValue> {
HeaderValue::from_str(str::from_utf8(self.content_encoding.as_ref()?).unwrap_or_default()).ok()
}
Expand Down
3 changes: 2 additions & 1 deletion src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,8 @@ impl Server {

// ---- Ordzaar ----
inscription_sequence: info.entry.sequence_number,
delegate: info.inscription.delegate()
delegate: info.inscription.delegate(),
content_encoding: info.inscription.content_encoding_str().map(|s| s.to_string()),
// ---- Ordzaar ----
})
.into_response()
Expand Down
3 changes: 2 additions & 1 deletion tests/json_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ fn get_inscription() {

// ---- Ordzaar ----
inscription_sequence: 0,
delegate: None
delegate: None,
content_encoding: None,
// ---- Ordzaar ----
}
)
Expand Down

0 comments on commit 760e99e

Please sign in to comment.