atagen

jelq

public

an http based roguelike rpg about jelqing

Star0
Watch0
ssh://brewery@pls.lobotomise.me:33/atagen/jelq.git

Blame: src/http/runs.rs

782069860236atagen2026-10-10 12:44 UTC1
//! The resources under `/runs/{id}`.
782069860236atagen2026-10-10 12:44 UTC2
782069860236atagen2026-10-10 12:44 UTC3
use axum::{
782069860236atagen2026-10-10 12:44 UTC4
    Json,
782069860236atagen2026-10-10 12:44 UTC5
    http::{StatusCode, header},
782069860236atagen2026-10-10 12:44 UTC6
    response::{IntoResponse, Response},
782069860236atagen2026-10-10 12:44 UTC7
};
782069860236atagen2026-10-10 12:44 UTC8
use serde_json::{Value, json};
782069860236atagen2026-10-10 12:44 UTC9
782069860236atagen2026-10-10 12:44 UTC10
use super::{
782069860236atagen2026-10-10 12:44 UTC11
    ctx::Ctx,
8b8e83329a1datagen2026-10-12 12:01 UTC12
    inventory::{delete_item, get_inventory, get_item},
8b8e83329a1datagen2026-10-12 12:01 UTC13
    parse::{parse_intensity, parse_techniques},
782069860236atagen2026-10-10 12:44 UTC14
    resource::{Resource, Verb},
782069860236atagen2026-10-10 12:44 UTC15
    response::respond,
782069860236atagen2026-10-10 12:44 UTC16
    run::{Greeting, RunResource, Scope},
8b8e83329a1datagen2026-10-12 12:01 UTC17
    shaft::{get_foreskin, get_length},
782069860236atagen2026-10-10 12:44 UTC18
};
782069860236atagen2026-10-10 12:44 UTC19
use crate::{
4f54028cba69atagen2026-10-14 11:45 UTC20
    game::{Branch, Cause, Floor, Grip, Item, Lube, Run, Technique, balance::VIEWS_PER_SECOND},
782069860236atagen2026-10-10 12:44 UTC21
    problem::Problem,
782069860236atagen2026-10-10 12:44 UTC22
};
782069860236atagen2026-10-10 12:44 UTC23
782069860236atagen2026-10-10 12:44 UTC24
const fn home(verbs: &'static [Verb<Run>]) -> RunResource {
782069860236atagen2026-10-10 12:44 UTC25
    RunResource {
782069860236atagen2026-10-10 12:44 UTC26
        scope: Scope::Home,
782069860236atagen2026-10-10 12:44 UTC27
        resource: Resource::new(verbs),
782069860236atagen2026-10-10 12:44 UTC28
    }
782069860236atagen2026-10-10 12:44 UTC29
}
782069860236atagen2026-10-10 12:44 UTC30
782069860236atagen2026-10-10 12:44 UTC31
const fn pockets(verbs: &'static [Verb<Run>]) -> RunResource {
782069860236atagen2026-10-10 12:44 UTC32
    RunResource {
782069860236atagen2026-10-10 12:44 UTC33
        scope: Scope::Pockets,
782069860236atagen2026-10-10 12:44 UTC34
        resource: Resource::new(verbs),
782069860236atagen2026-10-10 12:44 UTC35
    }
782069860236atagen2026-10-10 12:44 UTC36
}
782069860236atagen2026-10-10 12:44 UTC37
782069860236atagen2026-10-10 12:44 UTC38
fn not_in_clinic(run: &Run) -> bool {
782069860236atagen2026-10-10 12:44 UTC39
    run.floor != Floor::Clinic
782069860236atagen2026-10-10 12:44 UTC40
}
782069860236atagen2026-10-10 12:44 UTC41
782069860236atagen2026-10-10 12:44 UTC42
pub static RUN: RunResource = RunResource {
782069860236atagen2026-10-10 12:44 UTC43
    scope: Scope::Home,
6619c458c23eatagen2026-10-14 08:08 UTC44
    resource: Resource::new(&[
8b8e83329a1datagen2026-10-12 12:01 UTC45
        Verb::new("GET", get_run),
8b8e83329a1datagen2026-10-12 12:01 UTC46
        Verb::new("JELQ", jelq).only_when(not_in_clinic, "JELQ is not performed in the clinic."),
8b8e83329a1datagen2026-10-12 12:01 UTC47
        Verb::new("HOLD", hold_run).only_when(
8b8e83329a1datagen2026-10-12 12:01 UTC48
            Run::can_hold,
e028a4184d00atagen2026-10-14 10:49 UTC49
            "HOLD is only available once Swollen or at 2 stamina or less.",
8b8e83329a1datagen2026-10-12 12:01 UTC50
        ),
8b8e83329a1datagen2026-10-12 12:01 UTC51
        Verb::new("PUT", put_run),
8b8e83329a1datagen2026-10-12 12:01 UTC52
        Verb::new("DELETE", delete_run),
8b8e83329a1datagen2026-10-12 12:01 UTC53
        Verb::new("TRACE", trace_run),
8b8e83329a1datagen2026-10-12 12:01 UTC54
    ]),
782069860236atagen2026-10-10 12:44 UTC55
};
782069860236atagen2026-10-10 12:44 UTC56
pub static LENGTH: RunResource = home(&[Verb::new("GET", get_length)]);
782069860236atagen2026-10-10 12:44 UTC57
pub static FORESKIN: RunResource = home(&[
782069860236atagen2026-10-10 12:44 UTC58
    Verb::new("GET", get_foreskin),
782069860236atagen2026-10-10 12:44 UTC59
    Verb::new("DELETE", delete_foreskin),
782069860236atagen2026-10-10 12:44 UTC60
]);
782069860236atagen2026-10-10 12:44 UTC61
pub static INVENTORY: RunResource = pockets(&[Verb::new("GET", get_inventory)]);
782069860236atagen2026-10-10 12:44 UTC62
pub static ITEM: RunResource =
782069860236atagen2026-10-10 12:44 UTC63
    pockets(&[Verb::new("GET", get_item), Verb::new("DELETE", delete_item)]);
782069860236atagen2026-10-10 12:44 UTC64
pub static TECHNIQUES: RunResource = home(&[Verb::new("GET", get_techniques)]);
782069860236atagen2026-10-10 12:44 UTC65
pub static DRAWER: RunResource = home(&[Verb::new("POST", search_drawer)]);
782069860236atagen2026-10-10 12:44 UTC66
pub static BRANCH: RunResource = home(&[Verb::new("POST", choose_branch)]);
0a0bfee8329eatagen2026-10-11 05:11 UTC67
pub static KITCHEN: RunResource = home(&[Verb::new("POST", raid_kitchen)]);
0a0bfee8329eatagen2026-10-11 05:11 UTC68
pub static MELON: RunResource = home(&[Verb::new("POST", commit_melon)]);
a11497af08aaatagen2026-10-13 12:04 UTC69
pub static THREAD: RunResource = pockets(&[Verb::new("GET", get_thread)]);
782069860236atagen2026-10-10 12:44 UTC70
pub static FLOOR: RunResource =
0d604ee39751atagen2026-10-10 14:15 UTC71
    home(&[Verb::new("GET", get_floor), Verb::new("POST", leave_floor)]);
782069860236atagen2026-10-10 12:44 UTC72
pub static SHOP: RunResource = home(&[Verb::new("GET", get_shop)]);
782069860236atagen2026-10-10 12:44 UTC73
pub static BUY: RunResource = home(&[Verb::new("POST", buy)]);
782069860236atagen2026-10-10 12:44 UTC74
pub static PORTAL: RunResource = pockets(&[
782069860236atagen2026-10-10 12:44 UTC75
    Verb::new("GET", get_portal),
782069860236atagen2026-10-10 12:44 UTC76
    Verb::new("POST", accept_portal),
782069860236atagen2026-10-10 12:44 UTC77
]);
782069860236atagen2026-10-10 12:44 UTC78
pub static ELDER: RunResource = home(&[Verb::new("GET", get_elder)]);
782069860236atagen2026-10-10 12:44 UTC79
pub static GRIP: RunResource = home(&[Verb::new("GET", get_grip)]);
782069860236atagen2026-10-10 12:44 UTC80
pub static DIAGNOSIS: RunResource = pockets(&[Verb::new("GET", get_diagnosis)]);
782069860236atagen2026-10-10 12:44 UTC81
pub static FOOTAGE: RunResource = pockets(&[
782069860236atagen2026-10-10 12:44 UTC82
    Verb::new("GET", get_footage),
8b8e83329a1datagen2026-10-12 12:01 UTC83
    Verb::refused(
8b8e83329a1datagen2026-10-12 12:01 UTC84
        "DELETE",
782069860236atagen2026-10-10 12:44 UTC85
        "The footage has been cached by intermediaries. It cannot be deleted.",
782069860236atagen2026-10-10 12:44 UTC86
    ),
782069860236atagen2026-10-10 12:44 UTC87
]);
782069860236atagen2026-10-10 12:44 UTC88
782069860236atagen2026-10-10 12:44 UTC89
fn get_run(run: &mut Run, ctx: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC90
    if ctx
782069860236atagen2026-10-10 12:44 UTC91
        .header(header::ACCEPT)
782069860236atagen2026-10-10 12:44 UTC92
        .is_some_and(|accept| accept.contains("reassurance"))
782069860236atagen2026-10-10 12:44 UTC93
    {
782069860236atagen2026-10-10 12:44 UTC94
        return Problem::new(
782069860236atagen2026-10-10 12:44 UTC95
            StatusCode::NOT_ACCEPTABLE,
782069860236atagen2026-10-10 12:44 UTC96
            "no-reassurance",
782069860236atagen2026-10-10 12:44 UTC97
            "The server does not produce reassurance.",
782069860236atagen2026-10-10 12:44 UTC98
        )
782069860236atagen2026-10-10 12:44 UTC99
        .into_response();
782069860236atagen2026-10-10 12:44 UTC100
    }
782069860236atagen2026-10-10 12:44 UTC101
    (
782069860236atagen2026-10-10 12:44 UTC102
        StatusCode::OK,
782069860236atagen2026-10-10 12:44 UTC103
        [(header::ETAG, run.etag())],
782069860236atagen2026-10-10 12:44 UTC104
        Json(run.view()),
782069860236atagen2026-10-10 12:44 UTC105
    )
782069860236atagen2026-10-10 12:44 UTC106
        .into_response()
782069860236atagen2026-10-10 12:44 UTC107
}
782069860236atagen2026-10-10 12:44 UTC108
782069860236atagen2026-10-10 12:44 UTC109
fn jelq(run: &mut Run, ctx: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC110
    let parsed = parse_techniques(run, ctx).and_then(|techniques| {
782069860236atagen2026-10-10 12:44 UTC111
        let intensity = parse_intensity(ctx)?;
782069860236atagen2026-10-10 12:44 UTC112
        let lube = Lube::from_content_type(ctx.header(header::CONTENT_TYPE))?;
782069860236atagen2026-10-10 12:44 UTC113
        Ok((techniques, intensity, lube))
782069860236atagen2026-10-10 12:44 UTC114
    });
782069860236atagen2026-10-10 12:44 UTC115
    match parsed {
a6caa2f99786atagen2026-10-12 10:38 UTC116
        Ok((techniques, intensity, lube)) => respond(run.jelq(&techniques, intensity, lube)),
782069860236atagen2026-10-10 12:44 UTC117
        Err(problem) => problem.into_response(),
782069860236atagen2026-10-10 12:44 UTC118
    }
782069860236atagen2026-10-10 12:44 UTC119
}
782069860236atagen2026-10-10 12:44 UTC120
782069860236atagen2026-10-10 12:44 UTC121
fn put_run(run: &mut Run, _: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC122
    run.put().into_response()
782069860236atagen2026-10-10 12:44 UTC123
}
782069860236atagen2026-10-10 12:44 UTC124
a6caa2f99786atagen2026-10-12 10:38 UTC125
fn hold_run(run: &mut Run, _: &Ctx) -> Response {
a6caa2f99786atagen2026-10-12 10:38 UTC126
    respond(run.hold())
4347977b8192atagen2026-10-11 04:56 UTC127
}
4347977b8192atagen2026-10-11 04:56 UTC128
782069860236atagen2026-10-10 12:44 UTC129
fn delete_run(run: &mut Run, _: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC130
    run.end(Cause::Abandoned);
782069860236atagen2026-10-10 12:44 UTC131
    StatusCode::NO_CONTENT.into_response()
782069860236atagen2026-10-10 12:44 UTC132
}
782069860236atagen2026-10-10 12:44 UTC133
782069860236atagen2026-10-10 12:44 UTC134
fn trace_run(run: &mut Run, ctx: &Ctx) -> Response {
8b8e83329a1datagen2026-10-12 12:01 UTC135
    run.trace();
782069860236atagen2026-10-10 12:44 UTC136
    (
782069860236atagen2026-10-10 12:44 UTC137
        StatusCode::OK,
782069860236atagen2026-10-10 12:44 UTC138
        [(header::CONTENT_TYPE, "message/http")],
8b8e83329a1datagen2026-10-12 12:01 UTC139
        ctx.echo(),
ec6fd4bb5b60atagen2026-10-11 04:34 UTC140
    )
ec6fd4bb5b60atagen2026-10-11 04:34 UTC141
        .into_response()
782069860236atagen2026-10-10 12:44 UTC142
}
782069860236atagen2026-10-10 12:44 UTC143
782069860236atagen2026-10-10 12:44 UTC144
fn delete_foreskin(run: &mut Run, ctx: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC145
    respond(run.delete_foreskin(ctx.header(header::IF_MATCH)))
782069860236atagen2026-10-10 12:44 UTC146
}
782069860236atagen2026-10-10 12:44 UTC147
782069860236atagen2026-10-10 12:44 UTC148
fn get_techniques(run: &mut Run, _: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC149
    let listed: Vec<Value> = Technique::ALL
782069860236atagen2026-10-10 12:44 UTC150
        .into_iter()
880b29a0c11eatagen2026-10-13 09:27 UTC151
        .map(|t| t.describe(run.knows(t)))
782069860236atagen2026-10-10 12:44 UTC152
        .collect();
782069860236atagen2026-10-10 12:44 UTC153
    Json(json!({
782069860236atagen2026-10-10 12:44 UTC154
        "usage": format!("JELQ {}?technique=<name>[,<name>]&intensity=<1-10>", run.path("")),
782069860236atagen2026-10-10 12:44 UTC155
        "lubricant": "Declared with Content-Type.",
4f54028cba69atagen2026-10-14 11:45 UTC156
        "lubricants": Lube::content_types(),
782069860236atagen2026-10-10 12:44 UTC157
        "techniques": listed,
782069860236atagen2026-10-10 12:44 UTC158
    }))
782069860236atagen2026-10-10 12:44 UTC159
    .into_response()
782069860236atagen2026-10-10 12:44 UTC160
}
782069860236atagen2026-10-10 12:44 UTC161
782069860236atagen2026-10-10 12:44 UTC162
fn search_drawer(run: &mut Run, _: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC163
    respond(run.search_drawer())
782069860236atagen2026-10-10 12:44 UTC164
}
782069860236atagen2026-10-10 12:44 UTC165
782069860236atagen2026-10-10 12:44 UTC166
fn choose_branch(run: &mut Run, ctx: &Ctx) -> Response {
8b8e83329a1datagen2026-10-12 12:01 UTC167
    match ctx.param("choice").parse::<Branch>() {
8b8e83329a1datagen2026-10-12 12:01 UTC168
        Ok(choice) => respond(run.choose(choice)),
8b8e83329a1datagen2026-10-12 12:01 UTC169
        Err(()) => Problem::new(
8b8e83329a1datagen2026-10-12 12:01 UTC170
            StatusCode::NOT_FOUND,
8b8e83329a1datagen2026-10-12 12:01 UTC171
            "no-such-choice",
8b8e83329a1datagen2026-10-12 12:01 UTC172
            "That was not one of the choices.",
8b8e83329a1datagen2026-10-12 12:01 UTC173
        )
8b8e83329a1datagen2026-10-12 12:01 UTC174
        .into_response(),
8b8e83329a1datagen2026-10-12 12:01 UTC175
    }
782069860236atagen2026-10-10 12:44 UTC176
}
782069860236atagen2026-10-10 12:44 UTC177
782069860236atagen2026-10-10 12:44 UTC178
fn get_floor(run: &mut Run, _: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC179
    Json(run.floor_view()).into_response()
782069860236atagen2026-10-10 12:44 UTC180
}
782069860236atagen2026-10-10 12:44 UTC181
782069860236atagen2026-10-10 12:44 UTC182
fn leave_floor(run: &mut Run, _: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC183
    respond(run.advance())
782069860236atagen2026-10-10 12:44 UTC184
}
782069860236atagen2026-10-10 12:44 UTC185
782069860236atagen2026-10-10 12:44 UTC186
fn get_shop(run: &mut Run, _: &Ctx) -> Response {
8b8e83329a1datagen2026-10-12 12:01 UTC187
    respond(run.browse_shop().map(Json))
782069860236atagen2026-10-10 12:44 UTC188
}
782069860236atagen2026-10-10 12:44 UTC189
782069860236atagen2026-10-10 12:44 UTC190
fn buy(run: &mut Run, ctx: &Ctx) -> Response {
8b8e83329a1datagen2026-10-12 12:01 UTC191
    respond(run.buy(Item::parse(ctx.param("item"))))
782069860236atagen2026-10-10 12:44 UTC192
}
782069860236atagen2026-10-10 12:44 UTC193
0a0bfee8329eatagen2026-10-11 05:11 UTC194
fn raid_kitchen(run: &mut Run, _: &Ctx) -> Response {
0a0bfee8329eatagen2026-10-11 05:11 UTC195
    respond(run.raid_kitchen())
0a0bfee8329eatagen2026-10-11 05:11 UTC196
}
0a0bfee8329eatagen2026-10-11 05:11 UTC197
0a0bfee8329eatagen2026-10-11 05:11 UTC198
fn commit_melon(run: &mut Run, _: &Ctx) -> Response {
0a0bfee8329eatagen2026-10-11 05:11 UTC199
    respond(run.commit_melon())
0a0bfee8329eatagen2026-10-11 05:11 UTC200
}
0a0bfee8329eatagen2026-10-11 05:11 UTC201
a11497af08aaatagen2026-10-13 12:04 UTC202
fn get_thread(run: &mut Run, _: &Ctx) -> Response {
b85a0d4536c3atagen2026-10-11 08:50 UTC203
    respond(run.read_thread())
b85a0d4536c3atagen2026-10-11 08:50 UTC204
}
b85a0d4536c3atagen2026-10-11 08:50 UTC205
782069860236atagen2026-10-10 12:44 UTC206
fn get_portal(run: &mut Run, _: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC207
    Json(json!({
782069860236atagen2026-10-10 12:44 UTC208
        "terms": "By connecting you agree that the hotel is not responsible for anything that happens in this room, and that it does not want to know.",
782069860236atagen2026-10-10 12:44 UTC209
        "accept": { "href": run.path("/portal"), "method": "POST" },
782069860236atagen2026-10-10 12:44 UTC210
    }))
782069860236atagen2026-10-10 12:44 UTC211
    .into_response()
782069860236atagen2026-10-10 12:44 UTC212
}
782069860236atagen2026-10-10 12:44 UTC213
782069860236atagen2026-10-10 12:44 UTC214
fn accept_portal(run: &mut Run, _: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC215
    respond(run.accept_terms())
782069860236atagen2026-10-10 12:44 UTC216
}
782069860236atagen2026-10-10 12:44 UTC217
782069860236atagen2026-10-10 12:44 UTC218
fn get_elder(run: &mut Run, ctx: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC219
    respond(run.elder(
782069860236atagen2026-10-10 12:44 UTC220
        ctx.header(header::PROXY_AUTHORIZATION),
782069860236atagen2026-10-10 12:44 UTC221
        ctx.header(header::IF_MODIFIED_SINCE),
782069860236atagen2026-10-10 12:44 UTC222
    ))
782069860236atagen2026-10-10 12:44 UTC223
}
782069860236atagen2026-10-10 12:44 UTC224
782069860236atagen2026-10-10 12:44 UTC225
fn requested_grip(ctx: &Ctx) -> Option<Grip> {
782069860236atagen2026-10-10 12:44 UTC226
    let connection = ctx.header(header::CONNECTION)?.to_ascii_lowercase();
782069860236atagen2026-10-10 12:44 UTC227
    if !connection.split(',').any(|token| token.trim() == "upgrade") {
782069860236atagen2026-10-10 12:44 UTC228
        return None;
782069860236atagen2026-10-10 12:44 UTC229
    }
782069860236atagen2026-10-10 12:44 UTC230
    ctx.header(header::UPGRADE)?
782069860236atagen2026-10-10 12:44 UTC231
        .split(',')
8b8e83329a1datagen2026-10-12 12:01 UTC232
        .find_map(|protocol| protocol.trim().parse::<Grip>().ok())
782069860236atagen2026-10-10 12:44 UTC233
}
782069860236atagen2026-10-10 12:44 UTC234
782069860236atagen2026-10-10 12:44 UTC235
fn get_grip(run: &mut Run, ctx: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC236
    if let Some(grip) = requested_grip(ctx) {
058650ec79d6atagen2026-10-12 10:49 UTC237
        if let Err(problem) = run.set_grip(grip) {
058650ec79d6atagen2026-10-12 10:49 UTC238
            return problem.into_response();
058650ec79d6atagen2026-10-12 10:49 UTC239
        }
782069860236atagen2026-10-10 12:44 UTC240
        let mut response = (
782069860236atagen2026-10-10 12:44 UTC241
            StatusCode::SWITCHING_PROTOCOLS,
782069860236atagen2026-10-10 12:44 UTC242
            [
782069860236atagen2026-10-10 12:44 UTC243
                (header::UPGRADE, grip.name()),
782069860236atagen2026-10-10 12:44 UTC244
                (header::CONNECTION, "upgrade"),
782069860236atagen2026-10-10 12:44 UTC245
            ],
782069860236atagen2026-10-10 12:44 UTC246
        )
782069860236atagen2026-10-10 12:44 UTC247
            .into_response();
782069860236atagen2026-10-10 12:44 UTC248
        response.extensions_mut().insert(Greeting(format!(
782069860236atagen2026-10-10 12:44 UTC249
            "You are now jelqing {}.\r\n",
782069860236atagen2026-10-10 12:44 UTC250
            grip.name()
782069860236atagen2026-10-10 12:44 UTC251
        )));
782069860236atagen2026-10-10 12:44 UTC252
        return response;
782069860236atagen2026-10-10 12:44 UTC253
    }
782069860236atagen2026-10-10 12:44 UTC254
    let detail = match ctx.header(header::UPGRADE) {
782069860236atagen2026-10-10 12:44 UTC255
        Some(protocol) => {
782069860236atagen2026-10-10 12:44 UTC256
            format!("The server does not know the {protocol} grip. Grips are protocols.")
782069860236atagen2026-10-10 12:44 UTC257
        }
782069860236atagen2026-10-10 12:44 UTC258
        None => "Grips are protocols. Change grip by upgrading the connection.".to_owned(),
782069860236atagen2026-10-10 12:44 UTC259
    };
782069860236atagen2026-10-10 12:44 UTC260
    (
782069860236atagen2026-10-10 12:44 UTC261
        StatusCode::OK,
782069860236atagen2026-10-10 12:44 UTC262
        [(header::UPGRADE, "overhand, underhand")],
8b8e83329a1datagen2026-10-12 12:01 UTC263
        Json(json!({ "grip": run.grip().name(), "detail": detail })),
782069860236atagen2026-10-10 12:44 UTC264
    )
782069860236atagen2026-10-10 12:44 UTC265
        .into_response()
782069860236atagen2026-10-10 12:44 UTC266
}
782069860236atagen2026-10-10 12:44 UTC267
782069860236atagen2026-10-10 12:44 UTC268
fn get_diagnosis(run: &mut Run, ctx: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC269
    respond(run.diagnose(
782069860236atagen2026-10-10 12:44 UTC270
        ctx.header(header::AUTHORIZATION),
782069860236atagen2026-10-10 12:44 UTC271
        ctx.header(header::IF_NONE_MATCH),
782069860236atagen2026-10-10 12:44 UTC272
    ))
782069860236atagen2026-10-10 12:44 UTC273
}
782069860236atagen2026-10-10 12:44 UTC274
782069860236atagen2026-10-10 12:44 UTC275
fn get_footage(run: &mut Run, _: &Ctx) -> Response {
782069860236atagen2026-10-10 12:44 UTC276
    let Some((filmed, age)) = run.footage() else {
782069860236atagen2026-10-10 12:44 UTC277
        return Problem::new(
782069860236atagen2026-10-10 12:44 UTC278
            StatusCode::NOT_FOUND,
782069860236atagen2026-10-10 12:44 UTC279
            "no-footage",
782069860236atagen2026-10-10 12:44 UTC280
            "There is no footage. Yet.",
782069860236atagen2026-10-10 12:44 UTC281
        )
782069860236atagen2026-10-10 12:44 UTC282
        .into_response();
782069860236atagen2026-10-10 12:44 UTC283
    };
782069860236atagen2026-10-10 12:44 UTC284
    (
782069860236atagen2026-10-10 12:44 UTC285
        [
782069860236atagen2026-10-10 12:44 UTC286
            (
782069860236atagen2026-10-10 12:44 UTC287
                header::CACHE_CONTROL,
782069860236atagen2026-10-10 12:44 UTC288
                "public, max-age=31536000, immutable".to_owned(),
782069860236atagen2026-10-10 12:44 UTC289
            ),
782069860236atagen2026-10-10 12:44 UTC290
            (header::AGE, age.to_string()),
782069860236atagen2026-10-10 12:44 UTC291
            (header::LAST_MODIFIED, httpdate::fmt_http_date(filmed)),
782069860236atagen2026-10-10 12:44 UTC292
        ],
782069860236atagen2026-10-10 12:44 UTC293
        Json(json!({
782069860236atagen2026-10-10 12:44 UTC294
            "detail": "A recording. It is grainy. It is unmistakably you. It has been shared.",
8b8e83329a1datagen2026-10-12 12:01 UTC295
            "views": 1 + age * VIEWS_PER_SECOND,
782069860236atagen2026-10-10 12:44 UTC296
        })),
782069860236atagen2026-10-10 12:44 UTC297
    )
782069860236atagen2026-10-10 12:44 UTC298
        .into_response()
782069860236atagen2026-10-10 12:44 UTC299
}