pinakes-server: wire backup, session refresh, webhooks, and rate limit config
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: If2855d44cc700c0f65a5f5ac850ee3866a6a6964
This commit is contained in:
parent
4e91cb6679
commit
52f0b5defc
8 changed files with 257 additions and 105 deletions
|
|
@ -18,10 +18,10 @@ impl IntoResponse for ApiError {
|
|||
PinakesError::NotFound(msg) => (StatusCode::NOT_FOUND, msg.clone()),
|
||||
PinakesError::FileNotFound(path) => {
|
||||
// Only expose the file name, not the full path
|
||||
let name = path
|
||||
.file_name()
|
||||
.map(|n| n.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "unknown".to_string());
|
||||
let name = path.file_name().map_or_else(
|
||||
|| "unknown".to_string(),
|
||||
|n| n.to_string_lossy().to_string(),
|
||||
);
|
||||
tracing::debug!(path = %path.display(), "file not found");
|
||||
(StatusCode::NOT_FOUND, format!("file not found: {name}"))
|
||||
},
|
||||
|
|
@ -31,10 +31,10 @@ impl IntoResponse for ApiError {
|
|||
},
|
||||
PinakesError::DuplicateHash(msg) => (StatusCode::CONFLICT, msg.clone()),
|
||||
PinakesError::UnsupportedMediaType(path) => {
|
||||
let name = path
|
||||
.file_name()
|
||||
.map(|n| n.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "unknown".to_string());
|
||||
let name = path.file_name().map_or_else(
|
||||
|| "unknown".to_string(),
|
||||
|n| n.to_string_lossy().to_string(),
|
||||
);
|
||||
(
|
||||
StatusCode::BAD_REQUEST,
|
||||
format!("unsupported media type: {name}"),
|
||||
|
|
@ -74,7 +74,7 @@ impl IntoResponse for ApiError {
|
|||
let body = serde_json::to_string(&ErrorResponse {
|
||||
error: message.clone(),
|
||||
})
|
||||
.unwrap_or_else(|_| format!(r#"{{"error":"{}"}}"#, message));
|
||||
.unwrap_or_else(|_| format!(r#"{{"error":"{message}"}}"#));
|
||||
(status, [("content-type", "application/json")], body).into_response()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue