下拉刷新
项目详情
navbar_avatar分享
repo_avatar
HelloGitHub 评分
0 人评分
根据 SQL 和配置文件生成接口的工具
开源Apache-2.0
认领
收藏
分享
2.1k
星数
中文
Go
主语言
活跃
9
贡献者
1
Issues
组织
2.2
最新版本
117
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 期

评论

评分:
暂无精选评论