Expand description
§Scheme Handler Module
Provides custom URI scheme handlers for Tauri webview isolation.
§RESPONSIBILITIES
- Handle
land://custom protocol requests - Routing to local HTTP services via ServiceRegistry
- Forward HTTP requests (GET, POST, PUT, DELETE, PATCH) to local services
- Set appropriate CORS headers for webview isolation
- Handle CORS preflight requests (OPTIONS method)
- Implement basic caching for static assets
- Handle health checks and error scenarios
§ARCHITECTURAL ROLE
The Scheme module provides protocol-level isolation and routing for webviews:
land://code.editor.land/path ──► ServiceRegistry ──► http://127.0.0.1:PORT/path
│ │
▼ ▼
CORS Headers Set Local Service
Response§SECURITY
- All responses include Access-Control-Allow-Origin: land://code.editor.land
- Content-Type preserved from local service response
- CORS headers set appropriately for cross-origin requests
- Request validation and sanitization
Structs§
- Cache
Entry 🔒 - Cache entry for static asset caching
- DnsPort
- DNS port managed state structure
Statics§
- CACHE 🔒
- Simple in-memory cache for static assets
- SERVICE_
REGISTRY 🔒
Functions§
- Mime
From 🔒Extension - MIME type detection from file extension
- Scheme
- Initializes the scheme handler module
- Vscode
File Scheme Handler - Handles
vscode-file://custom protocol requests. - Vscode
Webview Scheme Handler - Custom URI scheme handler for
vscode-webview://requests. - build_
cached_ 🔒response - Build a response from cached data
- build_
cors_ 🔒preflight_ response - Build a CORS preflight response
- build_
error_ 🔒response - Build an error response with CORS headers
- forward_
http_ 🔒request - Forward an HTTP request to a local service
- get_
cached 🔒 - Get a cached response if available
- get_
cors_ 🔒origins - Get the appropriate Access-Control-Allow-Origin header for the current platform
- get_
land_ port - Get the port for a registered service
- get_
service_ 🔒registry - Get a reference to the global service registry
- init_
cache 🔒 - Initialize the static asset cache
- init_
service_ registry - Initialize the global service registry
- land_
scheme_ handler - Handles
land://custom protocol requests - land_
scheme_ handler_ async - Handles
land://custom protocol requests asynchronously - parse_
http_ 🔒response - Parse an HTTP response string into status, body, and headers
- parse_
land_ 🔒uri - Parse a land:// URI to extract domain and path
- register_
land_ service - Register a service with the land:// scheme
- set_
cached 🔒 - Store a response in the cache
- should_
cache 🔒 - Check if a path should be cached