File tree

2 files changed

+118
-1
lines changed

2 files changed

+118
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Perfect JSON API Example
1+
# Perfect JSON API Example [简体中文](README.zh_CN.md)
22

33
<p align="center">
44
<a href="http://perfect.org/get-involved.html" target="_blank">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Perfect JSON API 示例 [English](README.md)
2+
3+
<p align="center">
4+
<a href="http://perfect.org/get-involved.html" target="_blank">
5+
<img src="http://perfect.org/assets//perfect__2_0_0.jpg" alt="Get Involed with Perfect!" width="854" />
6+
</a>
7+
</p>
8+
9+
<p align="center">
10+
<a href="https://.com/PerfectlySoft/Perfect" target="_blank">
11+
<img src="http://www.perfect.org//Perfect_GH_button_1_Star.jpg" alt="Star Perfect On " />
12+
</a>
13+
<a href="http://stackoverflow.com/questions/tagged/perfect" target="_blank">
14+
<img src="http://www.perfect.org//perfect_gh_button_2_SO.jpg" alt="Stack Overflow" />
15+
</a>
16+
<a href="https://twitter.com/perfectlysoft" target="_blank">
17+
<img src="http://www.perfect.org//Perfect_GH_button_3_twit.jpg" alt="Follow Perfect on Twitter" />
18+
</a>
19+
<a href="http://perfect.ly" target="_blank">
20+
<img src="http://www.perfect.org//Perfect_GH_button_4_slack.jpg" alt="Join the Perfect Slack" />
21+
</a>
22+
</p>
23+
24+
<p align="center">
25+
<a href="https://developer.apple.com/swift/" target="_blank">
26+
<img src="https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat" alt="Swift 3.0">
27+
</a>
28+
<a href="https://developer.apple.com/swift/" target="_blank">
29+
<img src="https://img.shields.io/badge/Platforms-OS%20X%20%7C%20Linux%20-lightgray.svg?style=flat" alt="Platforms OS X | Linux">
30+
</a>
31+
<a href="http://perfect.org/licensing.html" target="_blank">
32+
<img src="https://img.shields.io/badge/License-Apache-lightgrey.svg?style=flat" alt="License Apache">
33+
</a>
34+
<a href="http://twitter.com/PerfectlySoft" target="_blank">
35+
<img src="https://img.shields.io/badge/[email protected]?style=flat" alt="PerfectlySoft Twitter">
36+
</a>
37+
<a href="http://perfect.ly" target="_blank">
38+
<img src="http://perfect.ly/badge.svg" alt="Slack Status">
39+
</a>
40+
</p>
41+
42+
一个Perfect JSON API示例
43+
44+
该项目通过SPM软件包管理器编译,是[Perfect](https://.com/PerfectlySoft/Perfect)项目之一</br>
45+
请确保您已经安装了Xcode 8.0或更高版本。
46+
47+
## 准备工作 - 使用Xcode 8
48+
49+
* 导出或下载工程
50+
* 在终端中,导航到目录并执行
51+
52+
```
53+
swift package generate-xcodeproj
54+
```
55+
56+
* 打开 `Perfect-JSON-API.xcodeproj`
57+
* 在"Project Settings"下的"Library Search Paths"中添加`$(PROJECT_DIR)`递归. **(这一步将不需要在更高版本的Xcode 8中做)**
58+
* 在Xcode的构建目标下拉来选择可执行文件
59+
* 在Xcode中使用(cmd-R)命令来编译运行项目工程
60+
61+
您将会在Xcode控制台看到如下输出:
62+
63+
```
64+
[INFO] Starting HTTP server on 0.0.0.0:8181 with document root ./webroot
65+
```
66+
67+
* 打开浏览器,通过 [http://localhost:8181/api/v1/people](http://localhost:8181/api/v1/people)访问
68+
69+
## 准备工作 - 使用终端
70+
71+
* 导出或下载工程;
72+
* 在终端中,导航到工程目录
73+
* 执行 `swift build`
74+
* 项目编译成功后, 请执行 `./.build/debug/Perfect-JSON-API`
75+
76+
您将会看到如下输出:
77+
78+
```
79+
[INFO] Starting HTTP server on 0.0.0.0:8181 with document root ./webroot
80+
```
81+
82+
* 打开浏览器,通过 [http://localhost:8181/api/v1/people](http://localhost:8181/api/v1/people)访问
83+
84+
## 已包含的路由
85+
86+
此API中包含下列演示路由:
87+
88+
* GET: [http://localhost:8181/](http://localhost:8181/) - 一个返回显示"Hello, world!"的HTML页面。
89+
* GET: [http://localhost:8181/api/v1/people](http://localhost:8181/api/v1/people) - 从模拟数据返回JSON形式的persons列表。
90+
* POST: [http://localhost:8181/api/v1/people](http://localhost:8181/api/v1/people) - 将一个person添加到内部模拟对象并返回一个JSON形式的数组. 请注意需要下列参数: `firstName`, `lastName`, `email`.
91+
* POST: [http://localhost:8181/api/v1/people/json](http://localhost:8181/api/v1/people/json) - 接受原本的JSON, 添加一个新的person, 返回一个新的列表. JSON是下面的格式:
92+
93+
``` javascript
94+
{
95+
"email": "[email protected]",
96+
"firstName": "Test",
97+
"lastName": "User"
98+
}
99+
```
100+
## Postman Collection
101+
102+
文件夹包含了一个Postman的URL集合的`Example-WeatherAPI.postman_collection`文件
103+
104+
如果已经安装了Postman,就可以导入文件并轻松使用请求路由
105+
106+
## 问题报告
107+
108+
目前我们已经把所有错误报告合并转移到了JIRA上,因此原有的错误汇报功能不能用于本项目。
109+
110+
您的任何宝贵建意见或建议,或者发现我们的程序有问题,欢迎您在这里告诉我们。[http://jira.perfect.org:8080/servicedesk/customer/portal/1](http://jira.perfect.org:8080/servicedesk/customer/portal/1)
111+
112+
目前问题清单请参考以下链接: [http://jira.perfect.org:8080/projects/ISS/issues](http://jira.perfect.org:8080/projects/ISS/issues)
113+
114+
115+
116+
## 更多内容
117+
关于Perfect更多内容,请参考[perfect.org](http://perfect.org)官网。

0 commit comments

Comments
 (0)