GET
Request for plain text
GET
/test
HTTP/1.1
Accept: */*
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Host: example.com
User-Agent: Mozilla/5.0
HTTP/1.1
200
OK
Content-Type: text/plain
Hello world!
response = RestMan.get "http://example.com/test"
response.code #=>200
response.headers #=> Hash
response.headers[:content_type] #=> text/plain
response.body #=> Hello world!
response = RestMan::Request.execute(
method: :get,
url: "http://example.com/test"
)
response.code #=>200
response.headers #=> Hash
response.headers[:content_type] #=> text/plain
response.body #=> Hello world!
resource = RestMan::Resource.new("http://example.com/test")
resposne = resource.get
response.code #=>200
response.headers #=> Hash
response.headers[:content_type] #=> text/plain
response.body #=> Hello world!
$ restman get http://example.com/test
Hello world!
Request for a static HTML page
GET
/about
HTTP/1.1
Accept: */*
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Host: example.com
User-Agent: Mozilla/5.0
HTTP/1.1
200
OK
Content-Type: text/html
<html>
<head>
<title>About Us</title></head>
<body>
...
</body>
</html>
response = RestMan.get "http://example.com/about", headers: {"User-Agent" => "Mozilla/5.0"}
response.code #=>200
response.headers #=> Hash
response.headers[:content_type] #=> text/html
response.body #=> <html> ...
response = RestMan::Request.execute(
method: :get,
url: "http://example.com/about",
headers: {"User-Agent" => "Mozilla/5.0"}
)
response.code #=>200
response.headers #=> Hash
response.headers[:content_type] #=> text/html
response.body #=> <html> ...
resource = RestMan::Resource.new("http://example.com/about")
resposne = resource.get({"User-Agent" => "Mozilla/5.0"})
response.code #=>200
response.headers #=> Hash
response.headers[:content_type] #=> text/html
response.body #=> <html> ...
$ restman get http://example.com/about
<html>
<head>
<title>About Us</title>
</head>
<body>
...
</body>
</html>
Request with custom headers
GET
/data
HTTP/1.1
Accept: application/json
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Host: example.com
If-None-Match: e22d62c1
User-Agent: rest-man/1.1.0 (darwin21 arm64) ruby/3.1.2p20
HTTP/1.1
200
OK
Content-Type: application/json
ETag: e22d62c1
{
"name": "John Hill",
"age": 30
}
response = RestMan.get "http://example.com/data", {accept: "application/json", "If-None-Match": "e22d62c1"}
response.code #=>200
response.headers #=> Hash
response.headers[:content_type] #=> application/json
response.headers[:etag] #=> "e22d62c1"
response.body #=> {"name": ...}
response = RestMan::Request.execute(
method: :get,
url: "http://example.com/data",
headers: {accept: "application/json", "If-None-Match": "e22d62c1"}
)
response.code #=>200
response.headers #=> Hash
response.headers[:content_type] #=> application/json
response.headers[:etag] #=> "e22d62c1"
response.body #=> {"name": ...}
resource = RestMan::Resource.new("http://example.com/data")
resposne = resource.get({
accept: "application/json",
"If-None-Match": "e22d62c1"
})
response.code #=>200
response.headers #=> Hash
response.headers[:content_type] #=> application/json
response.headers[:etag] #=> "e22d62c1"
response.body #=> {"name": ...}
RestMan CLI hasn't support customize headers currently.