Files
ps5upload/payload/include/webui_api.h
T
phantomptrandClaude Opus 5.5 d435ac27db console page: load only the active language's strings
The page embedded all 21 languages' cw_* strings (174 KiB of the 220 KiB gzip
budget). Now it embeds English only; every other language is a separate
build artifact (dist-console/strings/<lang>.json) gzip'd into the helper and
served at GET /strings/<lang>.json (Host/Origin checked, no token, immutable
year-long cache; the page asks with ?v=<hash of the strings>). The page shows
English until the chosen language arrives, falls back to English per key, and
stays in English (logged once) when a load fails.

Page: 607.1 KiB raw / 174.4 KiB gzip -> 357.5 KiB raw / 112.5 KiB gzip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RxCGb8Asp1A1AQYiv1kbgS
2026-10-17 10:49:30 -07:00

40 lines
2.1 KiB
C

/* The console web UI's JSON API (Home, Files): the webui_route_fn main.c hands to webui_start.
*
* Every route is POST with a JSON body and adapts it to a method the helper already serves
* (management through mgmt_rpc_dispatch, the data layer through ava1_data_rpc, both reached the
* way the AVA1 server reaches them), under one fixed identity: the console page owns the jobs it
* starts as "ps5upload-console-webui". The route table in webui_api.c is the allowlist: any other
* path answers 404, a known path with another method 405.
*
* POST /api/input-log {"events":["<line>",...]} is the one route that reaches no helper method: it
* appends the page's controller-input measurements to WEBUI_INPUTLOG_PATH (webui_inputlog.h),
* bodies over WEBUI_INPUTLOG_BODY_MAX answer 413, calls closer than 500 ms apart 429.
*
* Three GET routes sit outside the table: GET / serves the embedded page (webui_page.h),
* GET /api/token answers {"token":"<hex>"} and GET /strings/<lang>.json one language's embedded
* strings (webui_strings.h; an id not in that table answers 404), all after the server's
* Host/Origin check only. */
#ifndef PS5UPLOAD_WEBUI_API_H
#define PS5UPLOAD_WEBUI_API_H
#include <stddef.h>
#include <stdint.h>
#include "webui_http.h"
#include "webui_settings.h"
/* The settings the helper started with (main.c loads WEBUI_SETTINGS_PATH before webui_start):
* /api/settings answers them and /api/settings/set changes them. Call once, before webui_start. */
void webui_api_settings_init(const webui_settings_t *s);
/* A paired PC unregistered the tile (APP_UNREGISTER of WEBUI_TILE_TITLE_ID): the same as Settings ->
* tile off. Saves tile:false to WEBUI_SETTINGS_PATH (so the next start does not register it again)
* and asks the tile thread to remove it (webui_tile_request(0): unregister, then the tile folder and
* the staged /user/app copy are deleted). Returns at once; 0, or -1 when the save failed (the
* removal is requested either way). */
int webui_api_tile_off(void);
int webui_api_route(const webui_req_t *r, const uint8_t *body, size_t body_len, int fd);
#endif