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. - Builtins
Env - External resources required by some builtins:
templateneeds a templates directory anddba SQLite database file. - EnvOptions
- Read policy for the
nitr.envbuiltin. - Fetch
Options - Policy and limits applied to every outbound
fetchrequest. - Request
Cookies - Cookies parsed from a request’s
Cookieheader: values via indexing (req.cookies.session) and signed-cookie verification viareq.cookies:verify(name, secret). - Response
Cookies - Builder for response
Set-Cookieheaders, attached as thecookiesfield of helper-built response tables. The server serializes each entry into its ownSet-Cookieheader. - Sqlite
Pragmas - The pragma set applied to a connection when it is opened.
Functions§
- best_
match - Picks the best of
offeredmedia types for anAcceptheader value, honoring q-values andtype/*/*/*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_errorreceives andnitr.errinforeturns. A plain table (it serializes to JSON for free) that stringifies — and concatenates — as the concisekind: message (source:line)form via a cached metatable. - register_
builtins - Registers the selected builtins on the global
nitrnamespace table, using theBuiltinsEnvfor the resources some of them need. - reset_
outbound_ budget Non- fetch - Resets the per-request outbound budget. A no-op without the
fetchfeature, so the server can call it unconditionally. - set_
trace_ context Non- fetch - Records the inbound request id for
traceparentpropagation. A no-op without thefetchfeature.