项目详情
由
分享
HelloGitHub 评分
0 人评分
根据 SQL 和配置文件生成接口的工具
过去 7 天共收获 0 颗 Star ✨
使用方向键查看日期,Home 和 End 跳至首尾,Escape 关闭提示。| 日期 | Star | 较前日 |
|---|---|---|
| 周三 | 2,068 | — |
| 周四 | 2,068 | 0 |
| 周五 | 2,068 | 0 |
| 周六 | 2,068 | 0 |
| 周日 | 2,068 | 0 |
| 周一 | 2,068 | 0 |
| 周二 | 2,068 | 0 |
2.1k
星数
否
中文
Go
主语言
否
活跃
11
贡献者
2
Issues
否
组织
无
最新版本
119
Forks
Apache-2.0
协议
根据 SQL 和配置文件生成接口的工具。与传统的 SQL 生成 RESETful API 的工具不同,这个工具允许你自定义一些 API 的前、后处理,Auth 之类的行为。启动命令 `sqler -config=path to config file`,配置示例:
```
adduser {
// 参数校验
validators {
user_name_is_empty = "$input.user_name && $input.user_name.trim().length > 0"
user_email_is_empty = "$input.user_email && $input.user_email.trim(' ').length > 0"
user_password_is_not_ok = "$input.user_password && $input.user_password.trim(' ').length > 5"
}
bind {
name = "$input.user_name"
email = "$input.user_email"
password = "$input.user_password"
}
methods = ["POST"]
// 权限校验
authorizer = <<JS
(function(){
log("use this for debugging")
token = $input.http_authorization
response = fetch("http://requestbin.fullcontact.com/zxpjigzx", {
headers: {
"Authorization": token
}
})
if ( response.statusCode != 200 ) {
return false
}
return true
})()
JS
exec = <<SQL
INSERT INTO users(name, email, password, time) VALUES(:name, :email, :password, UNIX_TIMESTAMP());
SELECT * FROM users WHERE id = LAST_INSERT_ID();
SQL
}
```
收录于:
第 34 期
评论
评分:
暂无精选评论