API 网关(HTTP)
API 网关在腾讯云函数体系中类似于 HTTP 函数,我们通过它将函数发布为 HTTP 服务。
使用方式
import { Provide, Inject, ServerlessTrigger, ServerlessTriggerType } from '@midwayjs/decorator';
import { Context } from '@midwayjs/faas';
@Provide()
export class HelloTencentService {
@Inject()
ctx: Context;
@ServerlessTrigger(ServerlessTriggerType.API_GATEWAY, {
path: '/api_gateway_tencent',
method: 'post',
})
async handleAPIGatewayEvent(@Body() name) {
return `hello ${name}`;
}
}
在 npm run deploy
后即可通过控制台输出的链接访问。