Skip to main content

Crate nitr_std

Crate nitr_std 

Source
Expand description

The built-in nitr.* standard library for Nitr and its registration.

Every builtin mounts as a field of the global nitr namespace table (nitr.json, nitr.fetch, nitr.db, …) — Nitr registers no other globals, so scripts always read nitr.* and nothing is intermixed with the Lua standard library.

Re-exports§

pub use cache::Cache;
pub use cache::CacheOptions;

Modules§

cache
nitr.cache: a bounded, Rust-owned cache shared by every pooled state.

Structs§

Builtins
Built-in nitr.* standard library modules that can be exposed to Lua scripts.
BuiltinsEnv
External resources required by some builtins: template needs a templates directory and db a SQLite database file.
EnvOptions
Read policy for the nitr.env builtin.
FetchOptions
Policy and limits applied to every outbound fetch request.
RequestCookies
Cookies parsed from a request’s Cookie header: values via indexing (req.cookies.session) and signed-cookie verification via req.cookies:verify(name, secret).
ResponseCookies
Builder for response Set-Cookie headers, attached as the cookies field of helper-built response tables. The server serializes each entry into its own Set-Cookie header.
SqlitePragmas
The pragma set applied to a connection when it is opened.

Functions§

best_match
Picks the best of offered media types for an Accept header value, honoring q-values and type/* / */* wildcards. More specific ranges win at equal quality; ties go to the earlier offer.
error_lua_value
Builds the structured error value the error model hands to Lua: the table on_error receives and nitr.errinfo returns. A plain table (it serializes to JSON for free) that stringifies — and concatenates — as the concise kind: message (source:line) form via a cached metatable.
register_builtins
Registers the selected builtins on the global nitr namespace table, using the BuiltinsEnv for the resources some of them need.
reset_outbound_budgetNon-fetch
Resets the per-request outbound budget. A no-op without the fetch feature, so the server can call it unconditionally.
set_trace_contextNon-fetch
Records the inbound request id for traceparent propagation. A no-op without the fetch feature.