code wiki / _hdl_build / nx_route.nx

nx_route.nx

buildroot/runtime/_hdl_build/nx_route.nx

4056 B51 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic route
docsdependenciesstructsconstsfunctions

about

nx_route.nx -- the SOVEREIGN S-CLASS ROUTING ENGINE: one declarative pure function every delivery flows through, replacing per-path if-chains. URL path + a resource manifest -> a routing DECISION. S-class properties, uniform for ALL resources (qualitative: clean+canonical+safe; quantitative: one engine, every path handled the same): * CLEAN extensionless URLs: /vn -> serves vn.html ; /foo -> foo/index.html ; exact assets (/x.png,/x.css) served * ONE CANONICAL url: /vn.html -> 301 /vn ; /vn/ -> 301 /vn (trailing slash) -> no more "/vn vs /vn.html" mess * TRAVERSAL-SAFE: any ".." -> 400 (never serves outside the docroot) * deterministic + pure (path+manifest in, decision out) -> fully gateable with zero live-daemon risk. codes: 0=SERVE(out=file) 1=REDIRECT-301(out=location) 2=NOT-FOUND 3=BAD-REQUEST(traversal). license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_route.nx nx_route_gate.nx

imports: nx_syscalls.nx

imported by: nx_route_gate.nx

structs

none

consts

10const K_MAGIC_1024: i64 = 1024

functions

12func r_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 3: r_endsr_findroute
13func r_cpy(dst: *u8, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[i] = s[i]; i = i + 1 } dst[i] = 0 as u8; return i }
called by 1: route
14func r_cpyn(dst: *u8, s: *u8, n: i64) -> i64 { var i: i64 = 0; while i < n { dst[i] = s[i]; i = i + 1 } dst[i] = 0 as u8; return i }
called by 1: route
15func r_ends(s: *u8, suf: *u8) -> i64 { let ls: i64 = r_len(s); let lf: i64 = r_len(suf); if lf > ls { return 0 } var i: i64 = 0; while i < lf { if s[ls-lf+i] != suf[i] { return 0 } i = i + 1 } return 1 }
called by 1: route calls 1: r_len
16func r_dotdot(s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { if s[i] == (46 as u8) { if s[i+1] == (46 as u8) { return 1 } } i = i + 1 } return 0 }
called by 1: route
18func r_find(hay: *u8, needle: *u8) -> i64
called by 1: r_mem calls 1: r_len
25func r_mem(manifest: *u8, entry: *u8) -> i64
called by 1: route calls 2: sys_mmapr_find
32func route(path: *u8, manifest: *u8, out: *u8) -> i64