KScript docs
EN

Routes and APIs

The request

$request, or a controller's request parameter, is a map with these keys:

Key What it holds
method The method, in upper case.
path, url The path, and the path with its query.
query, form, json, input The query, the form fields, the JSON body, and all three together.
files Uploaded files by input name, each a list of { name, type, size, bytes }. See Uploaded files.
body The raw text of the body.
headers The headers, with lower-case names.
cookies The cookies, by name.
params The path parameters.
ip The client's address.
route The matched route's name, or null.
has_valid_signature True when the URL carries a signature from @signed_url() that matches it and hasn't run out.

A value in query or form is text. A name sent more than once (?tag=a&tag=b) is a list of texts, so no value is lost. A typed field says which you want: tags: string[] takes the name sent once or many times and is always a list, while tag: string answers 422 when it is sent twice.

How big a request may be

A body is held in memory while your code reads it, so the server takes only so much of one. A body with no files, such as a form post, JSON or plain text, may be 1 MiB; a bigger one is answered 413 before any of your code runs, and the rest of it is not read. http.body_limit in kscript.json changes that:

JSON
{
  "http": {
    "body_limit": "4MB"
  }
}

A form that uploads files is counted another way: its files may be 8 MiB in all (http.upload_limit, see Uploaded files) and each of its text fields 1 MiB. Raise a limit only as far as the largest request you expect, because every request being read at the same moment can hold that much.