atagen

jelq

public

an http based roguelike rpg about jelqing

Star0
Watch0

Commit 6f7c0593b2ca

tarball

atagen <boss@atagen.co>2026-10-14 09:09 UTC

3 files changed+19-2
http: name the cause of an ended run in X-Run-Over

The flavour text alone made the cause hard to pick out, and every later 410 only carried it as a problem URI.
Modified file: src/headers.rs+1 additions
@@ -12,6 +12,7 @@ pub const X_GAINS_ARRIVED: HeaderName = HeaderName::from_static("x-gains-arrived
1212 pub const X_GIRTH: HeaderName = HeaderName::from_static("x-girth");
1313 pub const X_LENGTH: HeaderName = HeaderName::from_static("x-length");
1414 pub const X_OBSERVED_BY: HeaderName = HeaderName::from_static("x-observed-by");
15+pub const X_RUN_OVER: HeaderName = HeaderName::from_static("x-run-over");
1516 pub const X_POWERED_BY: HeaderName = HeaderName::from_static("x-powered-by");
1617 pub const X_SEED: HeaderName = HeaderName::from_static("x-seed");
1718 pub const X_SELF_REPORTED_LENGTH: HeaderName = HeaderName::from_static("x-self-reported-length");
Modified file: src/http/run.rs+8 additions−2 deletions
@@ -17,7 +17,7 @@ use crate::{
1717 },
1818 headers::{
1919 X_CASH, X_EQ, X_FLOOR, X_FORESKIN, X_FRICTION, X_GAINS_ARRIVED, X_GIRTH, X_LENGTH,
20- X_OBSERVED_BY, X_SELF_REPORTED_LENGTH, X_SHAME, X_STAMINA, X_SUSPICION,
20+ X_OBSERVED_BY, X_RUN_OVER, X_SELF_REPORTED_LENGTH, X_SHAME, X_STAMINA, X_SUSPICION,
2121 },
2222 locale::Locale,
2323 problem::{PROBLEM_BASE, Problem},
@@ -80,8 +80,13 @@ pub fn serve(state: &AppState, mut ctx: Ctx, target: &RunResource) -> Response {
8080 return gone(ending.cause.slug(), ending.turn);
8181 }
8282 run.seen(ctx.now());
83- let response = gate(&mut run, &ctx, target.scope)
83+ let mut response = gate(&mut run, &ctx, target.scope)
8484 .unwrap_or_else(|| target.resource.dispatch(&mut run, &ctx));
85+ if let Some(ending) = &run.ended {
86+ response
87+ .headers_mut()
88+ .insert(X_RUN_OVER, HeaderValue::from_static(ending.cause.slug()));
89+ }
8590 let response = finish(&mut run, &ctx, &state.config.secret, response);
8691 let record = run.status().finished().then(|| Record::of(&run));
8792 (response, record)
@@ -103,6 +108,7 @@ fn gone(cause: &str, turn: u32) -> Response {
103108 .with("cause", format!("{PROBLEM_BASE}{cause}"))
104109 .with("turn", turn)
105110 .with("graveyard", "/graveyard")
111+ .header(X_RUN_OVER, cause)
106112 .into_response()
107113 }
108114
Modified file: src/tests/methods.rs+10 additions
@@ -129,3 +129,13 @@ async fn links_hide_resources_that_would_do_nothing() {
129129 let rels = linked_rels(&send(&clinic, "GET", "/runs/cafebabe", &[], "").await);
130130 assert!(rels.contains(&"diagnosis".to_owned()) && rels.contains(&"thread".to_owned()));
131131 }
132+
133+#[tokio::test]
134+async fn an_ended_run_names_its_cause() {
135+ let app = seeded_with(Floor::Bedroom, |_| {});
136+ let abandoned = send(&app, "DELETE", "/runs/cafebabe", &[], "").await;
137+ assert_eq!(header(&abandoned, "x-run-over"), "abandoned");
138+ let after = send(&app, "GET", "/runs/cafebabe", &[], "").await;
139+ assert_eq!(after.status(), StatusCode::GONE);
140+ assert_eq!(header(&after, "x-run-over"), "abandoned");
141+}