接口:BackendV0
容器方法
execInContainer
▸ execInContainer(container, cmd): Promise<
ExecResultV0>
在容器内执行命令。
const output = await window.ddClient.backend.execInContainer(container, cmd);
console.log(output);警告
它将在未来的版本中被移除。
参数
| Name | Type | Description |
|---|---|---|
container | string | - |
cmd | string | The command to be executed. |
返回
Promise<
ExecResultV0>
HTTP 方法
get
▸ get(url): Promise<unknown>
向后台服务执行HTTP GET请求。
window.ddClient.backend
.get("/some/service")
.then((value: any) => console.log(value));警告
它将在未来的版本中被移除。请使用 get 代替。
参数
| Name | Type | Description |
|---|---|---|
url | string | The URL of the backend service. |
返回
Promise<unknown>
post
▸ post(url, data): Promise<unknown>
向后台服务执行HTTP POST请求。
window.ddClient.backend
.post("/some/service", { ... })
.then((value: any) => console.log(value));警告
它将在未来的版本中被移除。请使用 post 代替。
参数
| Name | Type | Description |
|---|---|---|
url | string | The URL of the backend service. |
data | any | The body of the request. |
返回
Promise<unknown>
put
▸ put(url, data): Promise<unknown>
向后端服务执行HTTP PUT请求。
window.ddClient.backend
.put("/some/service", { ... })
.then((value: any) => console.log(value));警告
它将在未来的版本中被移除。请使用 put 代替。
参数
| Name | Type | Description |
|---|---|---|
url | string | The URL of the backend service. |
data | any | The body of the request. |
返回
Promise<unknown>
patch
▸ patch(url, data): Promise<unknown>
向后台服务执行HTTP PATCH请求。
window.ddClient.backend
.patch("/some/service", { ... })
.then((value: any) => console.log(value));警告
它将在未来的版本中被移除。请使用 patch 代替。
参数
| Name | Type | Description |
|---|---|---|
url | string | The URL of the backend service. |
data | any | The body of the request. |
返回
Promise<unknown>
delete
▸ delete(url): Promise<unknown>
向后台服务执行HTTP DELETE请求。
window.ddClient.backend
.delete("/some/service")
.then((value: any) => console.log(value));警告
它将在未来的版本中被移除。请使用 delete 代替。
参数
| Name | Type | Description |
|---|---|---|
url | string | The URL of the backend service. |
返回
Promise<unknown>
head
▸ head(url): Promise<unknown>
向后端服务执行HTTP HEAD请求。
window.ddClient.backend
.head("/some/service")
.then((value: any) => console.log(value));警告
它将在未来的版本中被移除。请使用 head 代替。
参数
| Name | Type | Description |
|---|---|---|
url | string | The URL of the backend service. |
返回
Promise<unknown>
request
▸ request(config): Promise<unknown>
向后台服务执行HTTP请求。
window.ddClient.backend
.request({ url: "/url", method: "GET", headers: { 'header-key': 'header-value' }, data: { ... }})
.then((value: any) => console.log(value));警告
它将在未来的版本中被移除。请使用 request 代替。
参数
| Name | Type | Description |
|---|---|---|
config | RequestConfigV0 | The URL of the backend service. |
返回
Promise<unknown>
虚拟机方法
execInVMExtension
▸ execInVMExtension(cmd): Promise<
ExecResultV0>
在后端容器内执行命令。
如果您的扩展附带了应该在后端容器内运行的额外二进制文件,您可以使用execInVMExtension函数。
const output = await window.ddClient.backend.execInVMExtension(
`cliShippedInTheVm xxx`
);
console.log(output);警告
它将在未来的版本中被移除。请使用 exec 代替。
参数
| Name | Type | Description |
|---|---|---|
cmd | string | The command to be executed. |
返回
Promise<
ExecResultV0>
spawnInVMExtension
▸ spawnInVMExtension(cmd, args, callback): void
返回从后端容器中执行的命令生成的流。
window.ddClient.spawnInVMExtension(
`cmd`,
[`arg1`, `arg2`],
(data: any, err: any) => {
console.log(data.stdout, data.stderr);
// Once the command exits we get the status code
if (data.code) {
console.log(data.code);
}
}
);警告
它将在未来的版本中被移除。
参数
| Name | Type | Description |
|---|---|---|
cmd | string | The command to be executed. |
args | string[] | The arguments of the command to execute. |
callback | (data: any, error: any) => void | The callback function where to listen from the command output data and errors. |
返回
void