api - 蒸汽构建失败
问题描述
Iam 目前是 Vapor Swift 服务器端的新手,最初我有两个查询
1)问题
蒸汽构建失败
错误:
构建失败。
2) 问题
运行时我得到 localhost:8080/Hello 这个 url 在 Safari 浏览器中工作正常
当谈到 Ios 应用程序时,我调用了我得到的 URl GET 方法
错误
获取 http:0.0.0.0:8080/Hello,HTTP 状态代码 503 时出错
如何在 Java、Javascript 等任何语言之外测试 Vapor Api
解决方案
您需要将 Vapor 绑定到0.0.0.0
(127.0.0.1
也可能在您的网络中工作)而不是localhost
(默认):
public func configure(
_ config: inout Config,
_ env: inout Environment,
_ services: inout Services
) throws {
services.register(EngineServerConfig.default(hostname: "0.0.0.0"))
...
}
如果你要部署到 heroku/etc,你可以在你的 Procfile 中设置它:
web: Run serve -e production -b 0.0.0.0:$PORT
推荐阅读
- mongodb - 如何合并 mongo 内联文档
- python - Python3-pip 安装:http://fr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 gcc-7 amd64 7.3.0-27ubuntu1~18.04 无法访问
- hapijs - 处理 CRUD 测试的最佳方法?
- java - How to release a guava cache object
- c++ - 从 JSON 像 DSL 到 qml 的转换
- reactjs - 如何在使用 withformik 和 antd 组件时调用 OnChange 函数?
- python - 如何确定多行 python 命令的位置(警告)?
- javascript - “skip if condition”和“direct return”之间的性能差异是什么?
- sql - 根据管道和大写分隔符将文本拆分为多行 - Oracle PL/SQL 流水线函数
- c# - using() 与 C# 中的本地范围对象