DebugParams

open class DebugParams

Declares the query parameters of a route (DebugRoute.query), and is the base of its body fields (DebugRoute.body). Each function adds one parameter and returns its handle, which the handler gives to DebugCall.get.

A parameter is optional, so its value is null when the request does not give it, until DebugParam.required or DebugParam.withDefault says otherwise. In the query or a form, an empty value of an int, long, double, or boolean parameter takes the parameter's default, and without a default it gets a 400, as other text that is not a number or true or false does: a request such as ?since= usually comes from a variable that has no value. An empty string is a string, which DebugStringSpec.minLength and DebugStringSpec.values can refuse. In a JSON body, null counts as absent, and the JSON type must match: a string parameter takes a JSON string, an int or long parameter a whole number, a double parameter any number, and a boolean parameter true or false.

Inheritors

Functions

Link copied to clipboard
fun boolean(name: String, declare: DebugParamSpec.() -> Unit = {}): DebugParam<Boolean?>

Declares a parameter named name that is true or false.

Link copied to clipboard
fun double(name: String, declare: DebugNumberSpec.() -> Unit = {}): DebugParam<Double?>

Declares a decimal parameter named name, such as 0.35 or 1e-3, as a Double, in the range of DebugNumberSpec.min and DebugNumberSpec.max when they are set. A whole number, such as 2, is a decimal too. NaN, the infinities, and a number too large for a Double get a 400: JSON can't carry them. In the query or a form, the value is written as a JSON number, optionally with a leading +, so 0x1p3 and 1d get a 400.

Link copied to clipboard
fun int(name: String, declare: DebugIntegerSpec.() -> Unit = {}): DebugParam<Int?>

Declares a whole-number parameter named name, from Int.MIN_VALUE to Int.MAX_VALUE unless DebugIntegerSpec.min and DebugIntegerSpec.max narrow it.

Link copied to clipboard
fun long(name: String, declare: DebugIntegerSpec.() -> Unit = {}): DebugParam<Long?>

Declares a whole-number parameter named name, as a Long.

Link copied to clipboard
fun string(name: String, declare: DebugStringSpec.() -> Unit = {}): DebugParam<String?>

Declares a string parameter named name.

Link copied to clipboard
fun strings(name: String, declare: DebugStringSpec.() -> Unit = {}): DebugParam<List<String>?>

Declares a string parameter named name that the request can give more than once, such as ?ids=a&ids=b: its value is every value that the request gives, in order, and each one must fit the options of declare. In a JSON body, the field is an array of strings.