Skip to content

Commit fd8102e

Browse files
committed
doc: updated the README.markdown
1 parent ac95cd2 commit fd8102e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.markdown

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ lua-resty-requests - Yet Another HTTP Library for OpenResty.
66
![Build Status](https://travis-ci.org/tokers/lua-resty-requests.svg?branch=master)
77

88
```bash
9-
resty -e 'print(require "resty.requests".get("https://github.com", { stream = false}).content)'
9+
resty -e 'print(require "resty.requests".get{ url = "https://github.com", stream = false }.content)'
1010
```
1111

1212
Table of Contents
@@ -101,6 +101,9 @@ ngx.print(body)
101101
-- end
102102
--
103103
-- ngx.print(r.content)
104+
105+
-- or you can use the shortcut way to make the code cleaner.
106+
local r, err = requests.get { url = url, stream = false }
104107
```
105108

106109
Installation
@@ -132,6 +135,7 @@ Methods
132135
### request
133136

134137
**syntax**: *local r, err = requests.request(method, url, opts?)*
138+
**syntax**: *local r, err = requests.request { method = method, url = url, ... }
135139

136140
This is the pivotal method in `lua-resty-requests`, it will return a [response object](#response-object) `r`. In the case of failure, `nil`, and a Lua string which describles the corresponding error will be given.
137141

@@ -242,6 +246,7 @@ The `Cookie` header will be `PHPSESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43
242246
* `stream`, takes a boolean value, specifies whether reading the body in the stream mode, and it will be true by default.
243247

244248
### state
249+
245250
**syntax**: *local state_name = requests.state(state)*
246251

247252
The method is used for getting the textual meaning of these values:
@@ -257,7 +262,9 @@ The method is used for getting the textual meaning of these values:
257262
a Lua string `"unknown"` will be returned if `state` isn't one of the above values.
258263

259264
### get
265+
260266
**syntax**: *local r, err = requests.get(url, opts?)*
267+
**syntax**: *local r, err = requests.get { url = url, ... }*
261268

262269
Sends a HTTP GET request. This is identical with
263270

@@ -267,6 +274,7 @@ requests.request("GET", url, opts)
267274

268275
### head
269276
**syntax**: *local r, err = requests.head(url, opts?)*
277+
**syntax**: *local r, err = requests.head { url = url, ... }*
270278

271279
Sends a HTTP HEAD request. This is identical with
272280

@@ -276,6 +284,7 @@ requests.request("HEAD", url, opts)
276284

277285
### post
278286
**syntax**: *local r, err = requests.post(url, opts?)*
287+
**syntax**: *local r, err = requests.post { url = url, ... }*
279288

280289
Sends a HTTP POST request. This is identical with
281290

@@ -285,6 +294,7 @@ requests.request("POST", url, opts)
285294

286295
### put
287296
**syntax**: *local r, err = requests.put(url, opts?)*
297+
**syntax**: *local r, err = requests.put { url = url, ... }*
288298

289299
Sends a HTTP PUT request. This is identical with
290300

@@ -294,6 +304,7 @@ requests.request("PUT", url, opts)
294304

295305
### delete
296306
**syntax**: *local r, err = requests.delete(url, opts?)*
307+
**syntax**: *local r, err = requests.delete { url = url, ... }*
297308

298309
Sends a HTTP DELETE request. This is identical with
299310

@@ -303,6 +314,7 @@ requests.request("DELETE", url, opts)
303314

304315
### options
305316
**syntax**: *local r, err = requests.options(url, opts?)*
317+
**syntax**: *local r, err = requests.options { url = url, ... }*
306318

307319
Sends a HTTP OPTIONS request. This is identical with
308320

@@ -312,6 +324,7 @@ requests.request("OPTIONS", url, opts)
312324

313325
### patch
314326
**syntax**: *local r, err = requests.patch(url, opts?)*
327+
**syntax**: *local r, err = requests.patch { url = url, ... }*
315328

316329
Sends a HTTP PATCH request. This is identical with
317330

0 commit comments

Comments
 (0)