KScript docs
EN

Built-in API gaps

Web and HTTP

Proposed API Today Gap
Matched route metadata and @route_is(name_or_pattern) A matched named HTTP route already exposes its name as $request.route. Match an active navigation item by stable name or canonical pattern. Cover unnamed HTTP routes and file-based pages without changing the existing string field.
@route_match(path, method: 'GET') The server matches routes internally. Calling @api dispatches a request. Inspect a match without invoking the handler. Return parameters and distinguish no match from method mismatch.
@asset_url(path) Templates write asset paths directly. The server serves compiled stylesheets at their public URL. Provide one place to build asset URLs for an asset base path or a versioned manifest.
@parse_query(text) @query_string(map) encodes a query. url.query and $request.query expose parsed maps. Parse standalone query strings with an explicit contract for repeated keys, empty values, and malformed encoding.
@sitemap() or a sitemap library Pages and handlers can write XML responses. Generate sitemap entries from an explicit public selection of routes plus any dynamic URLs supplied by the app. Build on @routes() once it exists.
Reuse fixed callable signatures HTTP middleware uses the shared fn(request: map, next: fn) contract for route loading and editor checks. Apply the same metadata to other arguments with a fixed calling convention as their contracts are defined. Plain fn callbacks can continue accepting any callable.
HTTP client defaults and retry policy @api(url, options: ...) accepts per-call options. response->check() raises for a failed response. Reuse a base URL, headers, timeouts, and cancellation policy across calls. Make retries opt-in and document which methods and failures qualify.
Outbound HTTP stubs for tests @api('/path') can call project routes in-process. Let unit tests supply responses or network failures for external URLs without opening a connection. Keep stubs scoped to the test.

Edit this page on GitHub