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