Checkpoint 按照 Amazon 的要求验证传入的 Alexa 请求 - Amazon 文档

用法

  1. Package.swift 中添加
.package(url: "https://github.com/vapor-community/checkpoint.git", from: "0.1.0")

并添加到依赖项

dependencies: ["Vapor", ..., "Checkpoint"]
  1. 您应该仅在 Amazon 将要调用您的技能的路由上使用此中间件。 您可以像这样操作
import Checkpoint
...
let alexa = router.grouped(Checkpoint.self)

//Alexa.self would be your struct you use to decode the request send by Amazon to your service
//You would need to most likely return a json following the specifications Amazon set
alexa.post(Alexa.self, at: "alexa") { req, alexa -> String in
  //do stuff with alexa and return the proper response
  return "Hi Alexa!"
}

作者

许可证

此项目基于 MIT 许可证 - 详见 LICENSE.md 文件

鸣谢