request 的字段与方法
字段是关于值的一个普通事实,用点号读取,不需要方括号:$value.name。方法会接收参数或执行操作,调用方式为 ->:$value->name(arguments),也可以把值通过管道传入:$value |> name(arguments)。
字段
| 字段 | 类型 | 说明 |
|---|---|---|
.body | string | 原始请求正文。 |
.cookies | map | 客户端发送的 Cookie。 |
.files | map | 按输入名称划分的上传文件,每个为 { name, type, size, bytes } 的列表,其中 bytes 为 base64:$request.files.avatar[0]。 |
.form | map | 提交的表单字段:$request.form.email。 |
.headers | map | 请求头,名称为小写。 |
.method | string | HTTP 方法,例如 GET 或 POST。 |
.params | map | 从请求路径中捕获的参数。 |
.path | string | 路径,例如 /people。 |
.query | map | 查询字符串的值:$request.query.page。 |
.route_info | map | 匹配的路由或基于文件的页面的元数据。 |
.scheme | string | 请求的协议,例如 http 或 https。 |
.url | string | 带查询字符串的路径,例如 /people?page=2。 |
来自 any 的方法
->convert(from?: 'json'|yaml|'csv'|'markdown'|'latex', to?: 'json'|yaml|'csv'|html|'markdown'|'latex', header?: bool, as?: type, headers?: list, indented?: bool)->from(type: 'json'|yaml|'csv'|'markdown'|'latex', header?: bool, as?: type)->is_a(type: word)->is_null()->or(fallback)->to(type: 'json'|yaml|'csv'|html|'markdown'|'latex', headers?: list, indented?: bool)->to_string()->type()