zjk
16 小时以前 8ea6a7dd1fcdbd4e22c564ed63a5a8023510161a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
# 本地联调辅助脚本:读 /tmp/token.txt 里的 token 调网关(token 不落终端输出)。
# 用法: sh .tmp_api.sh GET "/account/user/city/options"
#       sh .tmp_api.sh POST "/account/user/city" /tmp/body.json
M=$1
U=$2
B=$3
TOKEN=$(cat /tmp/token.txt)
# -g 关掉 curl 的 URL 通配:params[keyword]=xxx 里的方括号会被当成 glob 展开区间而报错
if [ -n "$B" ]; then
  curl -g -s --max-time 20 -X "$M" \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json;charset=utf-8" \
    --data-binary @"$B" \
    "http://localhost:8085$U"
else
  curl -g -s --max-time 20 -X "$M" -H "Authorization: Bearer $TOKEN" "http://localhost:8085$U"
fi
echo