mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-31 12:43:06 -07:00
global: snapshot + lock file + better errors
This commit is contained in:
@@ -97,17 +97,11 @@ fn req_to_response_res(
|
||||
s.into_response()
|
||||
}
|
||||
Output::Json(v) => {
|
||||
let json = match v {
|
||||
brk_interface::Value::Single(v) => serde_json::to_vec(&v)?,
|
||||
brk_interface::Value::List(v) => serde_json::to_vec(&v)?,
|
||||
brk_interface::Value::Matrix(v) => serde_json::to_vec(&v)?,
|
||||
};
|
||||
|
||||
let json = serde_json::to_vec(&v)?;
|
||||
if let GuardResult::Guard(g) = guard_res {
|
||||
g.insert(json.clone().into())
|
||||
.map_err(|_| Error::QuickCacheError)?;
|
||||
}
|
||||
|
||||
json.into_response()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,23 +102,23 @@ impl HeaderMapExtended for HeaderMap {
|
||||
.to_zoned(TimeZone::UTC)
|
||||
.datetime();
|
||||
|
||||
if let Some(if_modified_since) = self.get_if_modified_since() {
|
||||
if if_modified_since == date {
|
||||
return Ok((ModifiedState::NotModifiedSince, date));
|
||||
}
|
||||
if let Some(if_modified_since) = self.get_if_modified_since()
|
||||
&& if_modified_since == date
|
||||
{
|
||||
return Ok((ModifiedState::NotModifiedSince, date));
|
||||
}
|
||||
|
||||
Ok((ModifiedState::ModifiedSince, date))
|
||||
}
|
||||
|
||||
fn get_if_modified_since(&self) -> Option<DateTime> {
|
||||
if let Some(modified_since) = self.get(IF_MODIFIED_SINCE) {
|
||||
if let Ok(modified_since) = modified_since.to_str() {
|
||||
return strtime::parse(MODIFIED_SINCE_FORMAT, modified_since)
|
||||
.unwrap()
|
||||
.to_datetime()
|
||||
.ok();
|
||||
}
|
||||
if let Some(modified_since) = self.get(IF_MODIFIED_SINCE)
|
||||
&& let Ok(modified_since) = modified_since.to_str()
|
||||
{
|
||||
return strtime::parse(MODIFIED_SINCE_FORMAT, modified_since)
|
||||
.unwrap()
|
||||
.to_datetime()
|
||||
.ok();
|
||||
}
|
||||
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user