返回介绍

request.generateResponse(source, [options])

发布于 2024-02-12 19:53:56 字数 1669 浏览 0 评论 0 收藏 0

Returns a response which you can pass into the reply interface where:

  • source - the value to set as the source of the reply interface , optional.
  • options - optional object with the following optioal properties:
    • variety - a sting name of the response type (例如 'file' ).
    • prepare - a function with the signature async function(response) used to prepare the response after it is returned by a lifecycle method such as setting a file descriptor, where:
      • response - the response object being prepared.
      • must return the prepared response object (new object or response ).
      • may throw an error which is used as the prepared response.
    • marshal - a function with the signature async function(response) used to prepare the response for transmission to the client before it is sent, where:
      • response - the response object being marshaled.
      • must return the prepared value (not as response object) which can be any value accepted by the h.response() value argument.
      • may throw an error which is used as the marshaled value.
    • close - a function with the signature function(response) used to close the resources opened by the response object (例如 file handlers), where:
      • response - the response object being marshaled.
      • should not throw errors (which are logged but otherwise ignored).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文