iii-http-invoked-functions

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

HTTP-Invoked Functions

HTTP调用式函数

Use this pattern when iii should call external HTTP endpoints as functions.
当iii需要将外部HTTP端点作为函数调用时,请使用此模式。

Pattern selection rules

模式选择规则

  • If the task says "register HTTP endpoints with
    registerFunction
    ", use this pattern.
  • If the task asks for an endpoint list/map (for example
    { path, id }
    ) and a loop over
    registerFunction
    , use this pattern.
  • If the system being adapted cannot be modified, use this pattern.
  • If the goal is exposing inbound routes that iii owns, use
    registerTrigger({ type: 'http' })
    instead.
  • 如果任务要求“使用
    registerFunction
    注册HTTP端点”,请使用此模式。
  • 如果任务需要端点列表/映射(例如
    { path, id }
    )并循环调用
    registerFunction
    ,请使用此模式。
  • 如果待适配的系统无法修改,请使用此模式。
  • 如果目标是暴露iii所属的入站路由,请改用
    registerTrigger({ type: 'http' })

Core model

核心模型

  • registerFunction(meta, HttpInvocationConfig)
    registers an outbound HTTP-invoked function.
  • trigger({ function_id, payload })
    invokes it like any other function.
  • Trigger payload becomes request body for JSON-based calls.
  • Non-2xx and network failures are treated as invocation failures.
  • registerFunction(meta, HttpInvocationConfig)
    用于注册一个出站的HTTP调用式函数。
  • trigger({ function_id, payload })
    可像调用其他函数一样调用它。
  • 触发负载会成为基于JSON调用的请求体。
  • 非2xx状态码和网络故障会被视为调用失败。

Common shape

常见结构

  • registerWorker(url, { workerName })
  • Small endpoint descriptor list, then loop registration:
    • [{ path, id }]
    • registerFunction({ id }, { url: base + path, method: 'POST' })
  • Optional auth config with env var keys (
    token_key
    ,
    secret_key
    ,
    value_key
    )
  • registerWorker(url, { workerName })
  • 小型端点描述符列表,然后循环注册:
    • [{ path, id }]
    • registerFunction({ id }, { url: base + path, method: 'POST' })
  • 可选的包含环境变量键的认证配置(
    token_key
    secret_key
    value_key

Guardrails

约束规则

  • Do not model outbound HTTP endpoint adaptation as
    registerTrigger({ type: 'http' })
    .
  • Do not pass raw secrets in auth fields; pass env var names.
  • Keep function IDs stable and domain-prefixed (for example
    legacy::orders
    ).
  • 请勿将出站HTTP端点适配建模为
    registerTrigger({ type: 'http' })
  • 请勿在认证字段中传递原始密钥;请传递环境变量名称。
  • 保持函数ID稳定并带有领域前缀(例如
    legacy::orders
    )。

Reference

参考

See ../references/http-invoked-functions.js.
Also available in Python: ../references/http-invoked-functions.py
Also available in Rust: ../references/http-invoked-functions.rs
请查看../references/http-invoked-functions.js
也提供Python版本:../references/http-invoked-functions.py
也提供Rust版本:../references/http-invoked-functions.rs

When to Use

使用场景

  • Use this skill when the task is primarily about
    iii-http-invoked-functions
    in the iii engine.
  • Triggers when the request directly asks for this pattern or an equivalent implementation.
  • 当任务主要涉及iii引擎中的
    iii-http-invoked-functions
    时,请使用此技能。
  • 当请求直接要求此模式或等效实现时触发。

Boundaries

边界限制

  • Never use this skill as a generic fallback for unrelated tasks.
  • You must not apply this skill when a more specific iii skill is a better fit.
  • Always verify environment and safety constraints before applying examples from this skill.
  • 切勿将此技能作为无关任务的通用回退方案。
  • 当有更特定的iii技能更合适时,不得应用此技能。
  • 在应用此技能中的示例之前,请始终验证环境和安全约束。