想測(cè)試接口功能,get 請(qǐng)求還能在瀏覽器地址欄敲敲,測(cè)測(cè),post怎么模擬?
找到兩個(gè)不錯(cuò)的方法,一是postman; 二是使用curl
postman
chrome 添加postman interceptor, postman插件:

postman插件.png
打開(kāi)postman, 選擇create new => create a basic request

image.png
可以創(chuàng)建collection,類似于用文件夾來(lái)管理你的各種請(qǐng)求, 隨后輸入請(qǐng)求方式,參數(shù),點(diǎn)擊send就可以模擬發(fā)送請(qǐng)求了,下方就是response。postman, 你值得擁有

image.png
curl
百科一下:
curl是利用URL語(yǔ)法在命令行方式下工作的開(kāi)源文件傳輸工具。它被廣泛應(yīng)用在Unix、多種Linux發(fā)行版中,并且有DOS和Win32、Win64下的移植版本。
常用的參數(shù):
-d/ --data curl 默認(rèn)是get, -d/ —data可以指定post 傳遞的數(shù)據(jù)
-H/--header 自定義頭信息傳遞給服務(wù)器
-o -- output 將輸出寫到該文件中
-O -- remote-name 將輸出寫到該文件中 保留遠(yuǎn)程文件名
-T 上傳文件
舉個(gè)栗子:
curl http://localhost:8080/test
curl -d "x=1" http://localhost:8080/test
curl -H '' "x=1" http://localhost:8080/test