命令行工具CURL

利用curl可以很方便的调试SpringBoot程序。

curl的基本用法:

  • GET(不加-X参数就默认是Get方法)
curl http://127.0.0.1:8080/tvseries/
  • POST
curl -X POST --data '{"name": "West World", "originReleast": "2016-10-02"}' http://127.0.0.1:8080/tvseries/
  • 加上请求头
curl -H "Content-Type:application/json" -X POST --data '{"name": "West World", "originRelease": "2016-10-02"}' http://127.0.0.1:8080/tvseries/
  • PUT
curl -H "Content-Type:application/json" -X POST --data '{"name": "West World", "originReleast": "2016-10-02"}' http://127.0.0.1:8080/tvseries/33/
  • DELETE
curl -X DELETE --data http://127.0.0.1:8080/tvseries/33/
  • -help查看使用帮助
curl -help
  • -v 显示更详细的信息

测试工具postman:https://www.getpostman.com/

  • 上传文件(这里photo是指后端接收文件的参数名)
curl -F "photo=@demo.jpg" http://127.0.0.1:8080/tvseries/102/photos

-