m15o.net/wombat/sys/wom

NAME

wom - kernel

SYNOPSIS

req(v, p, d, ns)
mount(p, h, ns)
err(m)

DESCRIPTION

The kernel is the first file a host runs. It defines the calls below.

Req and mount take an optional namespace, ns: an object that maps names to paths, such as:

{ 'proc/': '/srv/proc/p1/' }

If a name in ns matches the start of p, it is replaced by its path, once, before the call goes on: with that namespace, proc/status means /srv/proc/p1/status.

A name ending in / matches everything under it, and any other name matches itself only. When several match, the longest wins. The result must start with /.

req(v, p, d, ns)

sends a 6b request with the verb v, the path p and the body d, after resolving p in the namespace ns. It returns the text of the response, which may be empty, or throws an error if the request fails. The body and the namespace are optional.

mount(p, h, ns)

makes the handler h answer requests for the path p, after resolving p in the namespace ns. If p ends in /, h also answers for everything under it. It returns an object whose dis function unmounts h, or throws an error if p is already mounted. The namespace is optional.

The handler is called as h(v, p, d, n) and returns the text of the response.

v

verb

p

path

d

body

n

passes the request to the server underneath and returns its response. Called with arguments, as n(v, p, d), it sends that request instead, and p is then a full path.

err(m)

throws an error whose message is the reason m. Below are the errors wom throws:

bad request

thrown when the path does not start with / after the namespace is applied, or when no server answers for it.

not found

thrown when nothing exists at the path.

not allowed

thrown when the resource does not accept the verb.

is a directory

thrown by a PUT with a body to a directory.

not a directory

thrown when the path passes through a file.

busy

thrown by a DEL when a server is mounted under the path, and by mount when the path is already mounted.

SOURCE

/sys/wom

SEE ALSO

odc(site:lib)

intro(doc), bat(sys), req(bin), 6b(doc)