Skip to content

Commit 4e4a072

Browse files
committed
2 parents 1c01173 + 927517d commit 4e4a072

File tree

2 files changed

+129
-1
lines changed

2 files changed

+129
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Perfect Turnstile with MySQL
1+
# Perfect Turnstile with MySQL [简体中文](README.zh_CN.md)
22

33
<p align="center">
44
<a href="http://perfect.org/get-involved.html" target="_blank">

README.zh_CN.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# 使用 MySQL 的 Perfect Turnstile 认证层 [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/github/perfect_github_2_0_0.jpg" alt="Get Involed with Perfect!" width="854" />
6+
</a>
7+
</p>
8+
9+
<p align="center">
10+
<a href="https://github.com/PerfectlySoft/Perfect" target="_blank">
11+
<img src="http://www.perfect.org/github/Perfect_GH_button_1_Star.jpg" alt="Star Perfect On Github" />
12+
</a>
13+
<a href="http://stackoverflow.com/questions/tagged/perfect" target="_blank">
14+
<img src="http://www.perfect.org/github/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/github/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/github/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+
该示例程序展示了使用 MySQL ORM 时集成 Stormpath 开发的 Turnstile 认证系统。
43+
44+
该认证库可以在 [https://github.com/PerfectlySoft/Perfect-Turnstile-MySQL](https://github.com/PerfectlySoft/Perfect-Turnstile-MySQL) 找到。
45+
46+
该包作为 [Perfect](https://github.com/PerfectlySoft/Perfect) 项目的一部分,可以通过 Swift 包管理器进行编译。
47+
48+
编译前请确保安装了 Xcode 8.0 或以上版本。
49+
50+
## 编译事项
51+
52+
### macOS
53+
54+
使用 Homebrew 包管理器安装 MySQL。
55+
56+
```
57+
brew install mysql
58+
```
59+
60+
若未安装 Homebrew,请使用下面命令进行安装:
61+
62+
```
63+
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
64+
```
65+
66+
安装完 MySQL 后需要编辑 mysqlclient.pc 文件,该文件在下面的路径中:
67+
68+
```
69+
/usr/local/lib/pkgconfig/mysqlclient.pc
70+
```
71+
72+
移除该文件中的 "fno-omit-frame-pointer" 项。该文件默认是只读的,所以在编辑前请先对该文件的读写权限进行修改。
73+
74+
### Linux
75+
76+
确保您为 MySQL 5.6 或更高版本安装了 libmysqlclient-dev:
77+
78+
```
79+
sudo apt-get install libmysqlclient-dev
80+
```
81+
82+
注意:Ubuntu 14 默认安装了无法成功编译的 MySQL 客户端。请手动安装 MySQL 5.6 或更高版本。
83+
84+
## 设置 - Xcode 8
85+
86+
* 检出或下载该项目;
87+
* 切换目录到项目根目录中并执行下面的命令
88+
89+
```
90+
swift package generate-xcodeproj
91+
```
92+
93+
* 打开 `PerfectTurnstile MySQL Demo.xcodeproj`
94+
95+
为了从 Xcode 中运行该项目,请编辑项目的 Scheme,"Options" 选择 "run",选中 "Use custom working directory" 并选择该项目的工作目录。做完这些设置后,该项目就可以从 Xcode 中运行了。
96+
97+
## 设置 - 终端
98+
99+
* 检出或下载该项目;
100+
* 切换目录到项目根目录中
101+
* 执行 `swift build`
102+
* 编译完成后,执行 `./.build/debug/PerfectTurnstile MySQL Demo`
103+
104+
```
105+
[INFO] Starting HTTP server on 0.0.0.0:8181 with document root ./webroot
106+
```
107+
108+
### JSON 路由
109+
110+
该框架包含了几个基本的路由:
111+
112+
```
113+
POST /api/v1/login (with username & password form elements)
114+
POST /api/v1/register (with username & password form elements)
115+
GET /api/v1/logout
116+
```
117+
118+
### 浏览器路由
119+
120+
下面的路由可用于浏览器测试:
121+
122+
```
123+
http://localhost:8181
124+
http://localhost:8181/login
125+
http://localhost:8181/register
126+
```
127+
128+
这些路由在 webroot 目录中使用了 Mustache 模板文件。

0 commit comments

Comments
 (0)