curl GET 请求
curl http://localhost:8080/api/user/list
curl http://localhost:8080/api/user/list -v
-v表示查看详细的请求信息
curl POST 请求
可以使用-X POST申明请求方法,-d传送参数
curl http://localhost:8080/api/article -X POST -d "title=title&homepage=AppBlog.CN"
这是一个普通的post请求,一般我们的接口都是json格式的,可以用-H参数申明请求的header
curl http://localhost:8080/api/article -X POST -H "Content-Type:application/json" -d '{"title":"title","homepage":"AppBlog.CN"}'
curl http://localhost:8080/email/send/async -X POST -H "Content-Type:application/json" -d '{"to":"test@iobeta.com","subject":"test","content":"content"}'
我们可以利用-H来设置更多的header,比如用户的token之类的
curl http://localhost:8080/api/article -X POST -H "Content-Type:application/json" -H "Authorization:Bearer xxx" -d '{"amount":"10.8"}'
curl POST 上传文件
curl指定参数-F "file=@__FILE_PATH__"即可传输文件:
curl http://localhost:8000/api/upimg -F "file=@/home/yezhou/test.png" -H "token: xxx" -v