跳转到主要内容

安装

Add InsForge to your Swift Package Manager dependencies:

Enable Logging (Optional)

For debugging, you can configure the SDK log level and destination:
Log Levels:
LevelDescription
.traceMost verbose, includes all internal details
.debugDetailed information for debugging
.infoGeneral operational information (default)
.warningWarnings that don’t prevent operation
.errorErrors that affect functionality
.criticalCritical failures
Log Destinations:
DestinationDescription
.consoleStandard output (print)
.osLogApple’s unified logging system (recommended for iOS/macOS)
.noneDisable logging
.customProvide your own LogHandler factory
Use .info or .error in production to avoid exposing sensitive data in logs.
目前,InsForge 仅支持在 Deno 环境中运行的 JavaScript/TypeScript 函数。

invoke()

按 slug 调用无服务器函数。

参数

  • slug (String) - 函数 slug/名称
  • body ([String: Any], optional) - 请求体作为字典

重载

invoke 方法有三个重载:
  1. 使用字典体,返回类型化响应
  2. 使用 Encodable 体,返回类型化响应
  3. 不期望响应体
SDK 自动包含来自登录用户的身份验证令牌。

示例

示例:基本调用与类型化响应

示例:使用 Encodable 请求体


错误处理