Skip to content

Commit

Permalink
doc: update api doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ch3cknull committed Dec 30, 2021
1 parent 5c24a45 commit 6f8ae13
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
24 changes: 23 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 枝网周年服务 API 文档
# 枝网 OAuth API 文档

## 获取新的 token

Expand Down Expand Up @@ -83,3 +83,25 @@ Authorization: token
"message": "ok"
}
```

## 获取机器人账号 UID

```http
GET /uid
```

### 响应

| 名称 | 解释 |
| ------- | ------------------- |
| code | 为 0 时,验证成功 |
| message | 报错信息,默认为 ok |
| uid | 机器人账号的 uid |

```json
{
"code": 0,
"message": "ok",
"uid": 114514
}
```
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,28 @@ luarocks install lua-resty-socket

0. 安装 OpenResty 和 Redis

1.`lua/config/config.lua.bak` 重命名为 `lua/config/config.lua` 并修改相应配置
1.`lua/config/config.lua.bak` 重命名为 `lua/config/config.lua` 并修改相应配置,必选配置项如下

2. 将自己机器人的 cookie 添加到 `lua/listener/constant.lua` 的 cookie 字段
- Redis 地址,密码,如果无密码请填写 `nil`
- 监听账号的 cookie,可配置多个,必选字段请参照文件内描述

3. 将这个文件夹的内容全部复制到 openresty 目录下的 nginx 下,**记得改好权限**
2. 将这个文件夹的内容全部复制到 openresty 目录下的 nginx 下,**记得改好权限**

4. 启动 openresty
3. 启动 openresty

4. 可选配置项有
- 用户 session,token 的过期时间
- 用户鉴权使用的头(尚在施工,目前只支持 `Authorization` 头)
- 根据 UID 做的黑名单

不复制文件可以选择在当前目录直接启动,需要添加参数,命令为

```sh
openresty -p `pwd` -c conf/nginx.conf
```

每次修改配置后,需要 `reload`

```sh
openresty -p `pwd` -c conf/nginx.conf -s reload
```
2 changes: 1 addition & 1 deletion lua/services/uid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ local account_id = cookie_map[random]
if account_id then
ngx.say(string.format([[{"code":0,"message":"ok","uid":"%s"}]], account_id))
else
ngx.say(string.format([[{"code":0,"message":"error","uid":null}]]))
ngx.say(string.format([[{"code":-1,"message":"error","uid":null}]]))
end

0 comments on commit 6f8ae13

Please sign in to comment.