winzik/engine/tests/fixtures/http-router.php
David Nurdin a74fe529a5 Web APIs: WebGL, page lifecycle, phone features, async HTTP, PWA, gamepads
- JsBridge both ways, synchronous with the frames (emscripten pre/postMainLoop);
  hide/close delivered at once between frames (jumphp_events)
- JumPHP\Gl\WebGl: 3D layer composed with the SDL picture (key colour / alpha),
  post-processing shaders, Mat4 (also software 3D on desktop)
- JumPHP\Device\Lifecycle (hide/show/blur/focus/online/offline/resize/close,
  pause_scene, mute when hidden) and Device (vibrate, wake lock, orientation,
  fullscreen, clipboard, tilt/motion, battery)
- JumPHP\Http: async requests (fetch / curl_multi / non-blocking sockets)
- JumPHP\Device\Pwa + sw.js: installable, offline, updates (game.yaml pwa)
- Gamepad: standard button names everywhere (pad0:a, pad0:start...), axes,
  hot-plug, rumble; Gamepad API in the browser
- games/hello-webgl example, docs/api-web.md, AGENTS.md

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 09:58:52 +01:00

20 lines
682 B
PHP

<?php
// php -S router for tests/Http/HttpTest.php
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
if ($path === '/json') {
header('Content-Type: application/json');
header('X-Test: yes');
echo json_encode(['method' => $_SERVER['REQUEST_METHOD'], 'body' => file_get_contents('php://input'),
'type' => $_SERVER['CONTENT_TYPE'] ?? '', 'ua' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
} elseif ($path === '/redirect') {
header('Location: /json', true, 302);
} elseif ($path === '/slow') {
sleep(3);
echo 'late';
} elseif ($path === '/big') {
echo str_repeat('0123456789', 50000);
} else {
http_response_code(404);
echo 'not found';
}