find_gateway_files (gateway-patch.py)

PocketClaw · integration, file-discovery, route-injection, gateway-patching, script-scanning, files

Finds gateway patch files in scripts directory for route injection.

#!/usr/bin/env python3
# Source: https://github.com/tinqiao-oss/PocketClaw | License: MIT | Copyright 2026 PocketClaw 项目作者
# Provided via justclaw.it.com; keep this notice with the code.
"""
PocketClaw Gateway Route Injector

Patches OpenClaw's gateway HTTP handler to serve custom static files
(e.g. mobile.html) before the control-ui SPA handler intercepts them.

Why this is needed:
  OpenClaw's gateway dispatches HTTP requests through an ordered list of
  "request stages" (runGatewayHttpRequestStages). The control-ui stage runs
  last and returns index.html for every unmatched path (SPA behavior).
  This patch unshifts a stage to the FRONT of that list so our custom files
  are served directly from disk before control-ui can swallow them.

Compatibility note (2026.6 rewrite):
  Up to Open

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key