curl 測試接口
curl 參考鏈接
-X POST; 定義請求方法為POST
-H "Content-Type:application/json"; 定義請求頭
-F "file=@/path/to/file"; 'POST' 'multipart/form-data ' 提交
-d "hello=world"; 提交的數據
GET
curl -d "hello=world" -d "test=curl" http://localhost/test/get
// http://localhost/test/get?hello=world&test=curl
POST
- 提交表單
curl -X POST -F "hello=world" -F "file=@/path/to/file.jpg" http://localhost/test/post/form
// 提交輸入內容和文件
- 提交json
curl -X POST -H "Content-Type:application/json" -d '{"hello": "world", "test": "curl"}' http://localhost/test/post/json
PUT
curl -X PUT -H "Content-Type:application/json" -d '{"hello": "world", "test": "curl"}' http://localhost/test/put
DELETE
curl -X DELETE -H "Content-Type:application/json" -d '{"hello": "world", "test": "curl"}' http://localhost/test/delete