路径:/check
请求方法:POST
接收的参数:
xxxxxxxxxx
41{
2 "username": "string",
3 "password": "string"
4}
返回结果:
如果用户名和密码与环境变量中的相同,则返回状态信息
如果不相同,则返回 401 Unauthorized
状态码和错误信息
xxxxxxxxxx
71curl -X POST \
2 http://127.0.0.1:18509/check \
3 -H 'Content-Type: application/json' \
4 -d '{
5 "username": "user01",
6 "password": "pass"
7 }'
如果验证通过,返回的状态信息为:
xxxxxxxxxx
11{"status": "success"}
如果验证不通过,返回的状态码为 401 Unauthorized
,错误信息为一段 JSON 格式的字符串。
路径:/rules
请求方法:POST
接收的参数:
xxxxxxxxxx
161[
2 {
3 "name": "规则名称1",
4 "target_sip_host": "153.101.117.6",
5 "destination_number_rule": ".",
6 "source_number_rule": ".",
7 "comment": "注释"
8 },
9 {
10 "name": "规则名称2",
11 "target_sip_host": "153.101.117.6",
12 "destination_number_rule": ".",
13 "source_number_rule": ".",
14 "comment": "注释"
15 }
16]
返回结果: 如果成功接收并存储了 JSON 数据,则返回状态信息
xxxxxxxxxx
91curl -X POST \
2 http://127.0.0.1:18509/rules \
3 -H 'Content-Type: application/json' \
4 -d '[{
5 "name": "4",
6 "target_sip_host": "153.101.117.6",
7 "destination_number_rule": ".",
8 "comment": "x"
9 }]'
如果数据成功存储,则返回的状态信息为:
xxxxxxxxxx
11{"status": "success"}
路径:/rules
请求方法:GET
接收的参数:无
返回结果:读取 data/rules.json
文件的内容并返回
xxxxxxxxxx
11curl http://127.0.0.1:18509/rules
返回读取的 JSON 数据,格式与存储时一致。