Repository Details
Shared by


HelloGitHub Rating
0 ratings
Free•Apache-2.0
Claim
Discuss
Collect
Share
2.1k
Stars
No
Chinese
Go
Language
No
Active
9
Contributors
1
Issues
No
Organization
2.2
Latest
117
Forks
Apache-2.0
License
More
根据 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
}
```
Included in:
Vol.34
Comments
Rating:
No comments yet