atagen

jelq

public

an http based roguelike rpg about jelqing

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