Skip to content
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
25 changes: 16 additions & 9 deletions rivet-cli/src/serve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,20 +1021,27 @@ async fn wrap_full_page(
&& !path.starts_with("/source-raw/")
&& !path.starts_with("/docs-asset/")
{
// Capture status before consuming the body so we can re-apply it after
// wrapping; otherwise .into_response() defaults to 200 and silently
// turns explicit error statuses (e.g. 400 from variant_error_response)
// into successful responses.
let status = response.status();
let bytes = axum::body::to_bytes(response.into_body(), 16 * 1024 * 1024)
.await
.unwrap_or_default();
let content = String::from_utf8_lossy(&bytes);
let app = state.read().await;
if is_print {
return layout::print_layout(&content, &app).into_response();
}
if is_embed {
return layout::embed_layout(&content, &app).into_response();
}
let active_variant = extract_variant_from_query(&query);
return layout::page_layout_with_variant(&content, &app, active_variant.as_deref())
.into_response();
let mut wrapped = if is_print {
layout::print_layout(&content, &app).into_response()
} else if is_embed {
layout::embed_layout(&content, &app).into_response()
} else {
let active_variant = extract_variant_from_query(&query);
layout::page_layout_with_variant(&content, &app, active_variant.as_deref())
.into_response()
};
*wrapped.status_mut() = status;
return wrapped;
}

response
Expand Down
Loading