Files, HTTP and JSON
What is still open for the file system, HTTP and JSON packages
The file system, the HTTP client and the HTTP host are built, as shipped packages, and JSON as nanyx.json, published
to the package index from nanyx-lang/json. What a program uses is in the
user docs: filesystem, file, dir and path
for nanyx.fs; client, http, request and
response for nanyx.http.core; The HTTP host and the
HTTP server cookbook for nanyx.http; and json,
decoders and encoders for nanyx.json. How the hosts implement them is on
Hosts and Foreign functions. This
page keeps what is still open.
The file system
- More than one
--allow-dir. The CLI’s option parser takes one value per option, sonanyx runtakes one extra directory;WasmRunnertakes any number. - A test host that provides
FileSystemin memory, with Testing.
HTTP
- Binary bodies. A body is a
string, because nothing in the library turns anArray(U8)into astring. Binary bodies come with a conversion between bytes and text. - A
.jsonhelper.Response.jsonwould makenanyx.http.coredepend onnanyx.json, and the HTTP host would want a constructor of that name as much as a client wants a reader. Whether to add it is open. - What the HTTP host still needs, route patterns,
LogandEnv, streamed bodies, serving beyondlocalhostand serving as awasi:httpcomponent, is on Serving HTTP.
JSON
- Encoding and decoding any record automatically (#1789) is
decided to wait for type reflection (Type members and reflection), which lets any
library walk a type’s structure, not just JSON’s. Deriving a JSON context in the compiler, as
EqandToStringare derived, was rejected: it would be a compiler special case that a SQL or YAML library couldn’t use. - Where the encoders live. They are in a module of their own,
nanyx.json/encode, because their names are the decoders’ (encode.string,json.string). Attaching them toEncoder(json.Encoder.string) would keep one module, since a type’s attached definitions are reached through an import’s alias (#1833); whether to move them is open. - The decoders’ file. They are in
json.typed.nyx, part of the modulejson. A partial module’s file can name a type from a file that sorts after it (#1838), so they could be laid out in other files; whether to is open.
Open questions
- Package names.
nanyx.fs,nanyx.http.core,nanyx.httpandnanyx.jsonare working names, as the console packages’ are (Hosts).