Skip to main content

Module Scheme

Module Scheme 

Source
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§

CacheEntry 🔒
Cache entry for static asset caching
DnsPort
DNS port managed state structure

Statics§

CACHE 🔒
Simple in-memory cache for static assets
SERVICE_REGISTRY 🔒

Functions§

MimeFromExtension 🔒
MIME type detection from file extension
Scheme
Initializes the scheme handler module
VscodeFileSchemeHandler
Handles vscode-file:// custom protocol requests.
VscodeWebviewSchemeHandler
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