#!/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