本文首發於我的博客kezunlin.me/post/4f5f98…,歡迎閱讀最新內容!linux
how to install and use resty command line client for interacting with rest servicesgit
You have curl, right? Okay.github
curl -L https://raw.githubusercontent.com/micha/resty/master/resty > resty複製代碼
Source the script before using it.chrome
. resty複製代碼
Once resty is installed, set your REST host to which you will be making your requests.shell
resty http://127.0.0.1:8080/data
http://127.0.0.1:8080/data*複製代碼
And now you can Make some HTTP requests.json
$ GET /blogs.json
[ {"id" : 1, "title" : "first post", "body" : "This is the first post"}, ... ]複製代碼
$ PUT /blogs/2.json '{"id" : 2, "title" : "updated post", "body" : "This is the new."}'
{"id" : 2, "title" : "updated post", "body" : "This is the new."}複製代碼
$ DELETE /blogs/2複製代碼
$ POST /blogs.json '{"title" : "new post", "body" : "This is the new new."}'
{"id" : 204, "title" : "new post", "body" : "This is the new new."}複製代碼
source resty [-W] [remote] [OPTIONS] # load functions into shell
resty [-v] # prints current request URI base
resty <remote> [OPTIONS] # sets the base request URI複製代碼
HEAD [path] [OPTIONS] # HEAD request
OPTIONS [path] [OPTIONS] # OPTIONS request
GET [path] [OPTIONS] # GET request
DELETE [path] [OPTIONS] # DELETE request
PUT [path] [data] [OPTIONS] # PUT request
PATCH [path] [data] [OPTIONS] # PATCH request
POST [path] [data] [OPTIONS] # POST request
TRACE [path] [OPTIONS] # TRACE request複製代碼
Options:複製代碼
-Q Don't URL encode the path.
-q <query> Send query string with the path. A '?' is prepended to
<query> and concatenated onto the <path>.
-W Don't write to history file (only when sourcing script).
-V Edit the input data interactively in 'vi'. (PUT, PATCH,
and POST requests only, with data piped to stdin.)
-Z Raw output. This disables any processing of HTML in the
response.
-v Verbose output. When used with the resty command itself
this prints the saved curl options along with the current
URI base. Otherwise this is passed to curl for verbose
curl output.
--dry-run Just output the curl command.
<curl opt> Any curl options will be passed down to curl.複製代碼
Postman is a collaboration platform for API development. Postman's features simplify each step of building an API and streamline collaboration so you can create better APIs—fasterapi
download Postman-linux-x64-7.10.0.tar.gz
from hereless
tar xzvf Postman-linux-x64-7.10.0.tar.gz
cd Postman
./Postman複製代碼
now we can create free account and play with postman.curl
F12--->Network.ide
A simple HTTP Request & Response Service.
see httpbin