创建 Lambda
创建带有源码或静态内容以及路由元数据的 lambda。
认证
需要 X-Glue-Authentication。
请求体
| 字段 | 类型 | 描述 |
|---|---|---|
name |
string | 可读的 lambda 名称 |
language |
string | javascript、static-html、static-css 或 static-js |
code |
string | 源码或静态内容 |
method |
string | lambda 路由的 HTTP 方法 |
path |
string | lambda 路由的 HTTP path |
HTTP 请求
1POST /api/v0/lambdas HTTP/1.1
2Host: api.hola.cloud
3X-Glue-Authentication: YOUR_TOKEN
4Content-Type: application/json
5
6{
7 "name": "hello-world",
8 "language": "javascript",
9 "method": "GET",
10 "path": "/hello-world",
11 "code": "export default (req) => ({ body: { message: 'Hello, World!' } })"
12}
示例
1curl -X POST "https://api.hola.cloud/api/v0/lambdas" \
2 -H "X-Glue-Authentication: YOUR_TOKEN" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "name": "hello-world",
6 "language": "javascript",
7 "method": "GET",
8 "path": "/hello-world",
9 "code": "export default (req) => ({ body: { message: \"Hello, World!\" } })"
10 }'
响应
1{
2 "id": "f1a2b3c4-d5e6-7890-abcd-ef0123456789",
3 "created_timestamp": 1751378400,
4 "owner": "user_123",
5 "project_id": "project_456",
6 "name": "hello-world",
7 "language": "javascript",
8 "code": "export default (req) => ({ body: { message: \"Hello, World!\" } })",
9 "method": "GET",
10 "path": "/hello-world"
11}
错误码
| 代码 | 描述 |
|---|---|
| 400 | 必填字段缺失或无效 |
| 401 | 认证缺失或无效 |
| 409 | 已存在同名 lambda |
评论