Http module

created

procedure · 1 overloadsince 0.30.0Source

value as JSON with status 201 and, when location is given, a Location header: the answer to a request that made something.

Example
response := created(42, tprint("/users/%", 42));

assert(response.status == 201);
location, found := find_header(response.headers, "Location");
assert(found && location == "/users/42");

Doesn't run in the browser (skipped on wasm).

created :: (value: $T, location := "") -> Response

value as JSON with status 201 and, when location is given, a Location header: the answer to a request that made something.

Parameters

value: $T
location := ""

Returns

Example
response := created(42, tprint("/users/%", 42));

assert(response.status == 201);
location, found := find_header(response.headers, "Location");
assert(found && location == "/users/42");

Doesn't run in the browser (skipped on wasm).

See also