Skip to content
This repository was archived by the owner on Sep 8, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/sandboxwich-api/src/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub(crate) async fn enforce_tenant_limits(
)
.await
{
return response;
return *response;
}
if is_mutating(request.method())
&& let Err(response) = consume(
Expand All @@ -82,7 +82,7 @@ pub(crate) async fn enforce_tenant_limits(
)
.await
{
return response;
return *response;
}
next.run(request).await
}
Expand All @@ -104,7 +104,7 @@ async fn consume(
kind: CounterKind,
limit: u32,
window_seconds: u32,
) -> Result<(), Response> {
) -> Result<(), Box<Response>> {
let now = Utc::now();
let expires = now + ChronoDuration::seconds(i64::from(window_seconds));
let sql = format!(
Expand All @@ -129,7 +129,7 @@ async fn consume(
.bind(i64::from(limit))
.fetch_optional(&db.pool)
.await
.map_err(|error| ApiError::from(error).into_response())?;
.map_err(|error| Box::new(ApiError::from(error).into_response()))?;
if row.is_some() {
return Ok(());
}
Expand All @@ -154,7 +154,7 @@ async fn consume(
HeaderValue::from_str(&retry_after.to_string())
.expect("positive seconds are a valid header"),
);
Err(response)
Err(Box::new(response))
}

async fn counter_retry_after(db: &Database, tenant: &str, kind: CounterKind) -> Option<i64> {
Expand Down
Loading