Skip to content

Commit aed15a6

Browse files
committed
readme update for v0.6 release
1 parent eb758fb commit aed15a6

File tree

1 file changed

+35
-36
lines changed

1 file changed

+35
-36
lines changed

README.md

+35-36
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
# resty [![Build Status](https://travis-ci.org/go-resty/resty.svg?branch=master)](https://travis-ci.org/go-resty/resty) [![GoCover](http://gocover.io/_badge/github.com/go-resty/resty)](http://gocover.io/github.com/go-resty/resty) [![GoReport](http://goreportcard.com/badge/go-resty/resty)](http://goreportcard.com/report/go-resty/resty) [![GoDoc](https://godoc.org/github.com/go-resty/resty?status.svg)](https://godoc.org/github.com/go-resty/resty) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
22

3-
Simple HTTP and REST client for Go inspired by Ruby rest-client. [Features](#features) section describes in detail about resty.
3+
Simple HTTP and REST client for Go inspired by Ruby rest-client. [Features](#features) section describes in detail about resty capabilities.
44

5-
***v0.5 released and tagged on Jan 03, 2016.***
5+
***v0.6 released on Feb 03, 2016.***
66

77
#### Features
88
* GET, POST, PUT, DELETE, HEAD, PATCH and OPTIONS
99
* Simple and chainable methods for settings and request
1010
* Request Body can be `string`, `[]byte`, `struct`, `map` and `io.Reader` too
11-
* Auto detect `Content-Type`
12-
* Response object gives you more possibility
11+
* Auto detects `Content-Type`
12+
* [Response](https://godoc.org/github.com/go-resty/resty#Response) object gives you more possibility
1313
* Access as `[]byte` array - `response.Body()` OR Access as `string` - `response.String()`
1414
* Know your `response.Time()` and when we `response.ReceivedAt()`
15-
* Have a look [godoc](https://godoc.org/github.com/go-resty/resty#Response)
1615
* Automatic marshal and unmarshal for `JSON` and `XML` content type
1716
* Default is `JSON`, if you supply `struct/map` without header `Content-Type`
1817
* Easy to upload one or more file(s) via `multipart/form-data`
19-
* Client [Request](https://godoc.org/github.com/go-resty/resty#Client.OnBeforeRequest) and [Response](https://godoc.org/github.com/go-resty/resty#Client.OnAfterResponse) middlewares
18+
* resty client [Request](https://godoc.org/github.com/go-resty/resty#Client.OnBeforeRequest) and [Response](https://godoc.org/github.com/go-resty/resty#Client.OnAfterResponse) middlewares
2019
* Authorization option of `BasicAuth` and `Bearer` token
2120
* Set request `ContentLength` value for all request or particular request
2221
* Choose between HTTP and REST mode. Default is `REST`
23-
* `HTTP` - default upto 10 redirects and no automatic response unmarshal
22+
* `HTTP` - default up to 10 redirects and no automatic response unmarshal
2423
* `REST` - defaults to no redirects and automatic response marshal/unmarshal for `JSON` & `XML`
2524
* Custom [Root Certificates](https://godoc.org/github.com/go-resty/resty#Client.SetRootCertificate) and Client [Certificates](https://godoc.org/github.com/go-resty/resty#Client.SetCertificates)
2625
* Download/Save HTTP response directly into File, like `curl -o` flag. See [SetOutputDirectory](https://godoc.org/github.com/go-resty/resty#Client.SetOutputDirectory) & [SetOutput](https://godoc.org/github.com/go-resty/resty#Request.SetOutput).
2726
* Cookies for your request and CookieJar support
2827
* Client settings like `Timeout`, `RedirectPolicy`, `Proxy`, `TLSClientConfig`, `Transport`, etc.
29-
* Client API design
28+
* Client API design
3029
* Have client level settings & options and also override at Request level if you want to
3130
* Create Multiple clients if want to `resty.New()`
3231
* goroutine concurrent safe
@@ -42,7 +41,7 @@ resty tested with Go `v1.2` and above.
4241
* FlexibleRedirectPolicy
4342
* DomainCheckRedirectPolicy
4443
* etc. [more info](redirect.go)
45-
* etc (upcoming - throw your idea's via [issues](https://github.com/go-resty/resty/issues)).
44+
* etc (upcoming - throw your idea's [here](https://github.com/go-resty/resty/issues)).
4645

4746
## Installation
4847
#### Stable - Version
@@ -88,13 +87,13 @@ Response Status: 200 OK
8887
Response Time: 644.290186ms
8988
Response Recevied At: 2015-09-15 12:05:28.922780103 -0700 PDT
9089
Response Body: {
91-
"args": {},
90+
"args": {},
9291
"headers": {
93-
"Accept-Encoding": "gzip",
94-
"Host": "httpbin.org",
92+
"Accept-Encoding": "gzip",
93+
"Host": "httpbin.org",
9594
"User-Agent": "go-resty v0.1 - https://github.com/go-resty/resty"
96-
},
97-
"origin": "0.0.0.0",
95+
},
96+
"origin": "0.0.0.0",
9897
"url": "http://httpbin.org/get"
9998
}
10099
*/
@@ -103,7 +102,7 @@ Response Body: {
103102
```go
104103
resp, err := resty.R().
105104
SetQueryParams(map[string]string{
106-
"page_no": "1",
105+
"page_no": "1",
107106
"limit": "20",
108107
"sort":"name",
109108
"order": "asc",
@@ -131,29 +130,29 @@ resp, err := resty.R().
131130
SetBody(`{"username":"testuser", "password":"testpass"}`).
132131
SetResult(&AuthSuccess{}). // or SetResult(AuthSuccess{}).
133132
Post("https://myapp.com/login")
134-
133+
135134
// POST []byte array
136135
// No need to set content type, if you have client level setting
137136
resp, err := resty.R().
138137
SetHeader("Content-Type", "application/json").
139138
SetBody([]byte(`{"username":"testuser", "password":"testpass"}`)).
140139
SetResult(&AuthSuccess{}). // or SetResult(AuthSuccess{}).
141140
Post("https://myapp.com/login")
142-
141+
143142
// POST Struct, default is JSON content type. No need to set one
144143
resp, err := resty.R().
145144
SetBody(User{Username: "testuser", Password: "testpass"}).
146145
SetResult(&AuthSuccess{}). // or SetResult(AuthSuccess{}).
147146
SetError(&AuthError{}). // or SetError(AuthError{}).
148147
Post("https://myapp.com/login")
149-
148+
150149
// POST Map, default is JSON content type. No need to set one
151150
resp, err := resty.R().
152151
SetBody(map[string]interface{}{"username": "testuser", "password": "testpass"}).
153152
SetResult(&AuthSuccess{}). // or SetResult(AuthSuccess{}).
154153
SetError(&AuthError{}). // or SetError(AuthError{}).
155154
Post("https://myapp.com/login")
156-
155+
157156
// POST of raw bytes for file upload. For example: upload file to Dropbox
158157
fileBytes, _ := ioutil.ReadFile("/Users/jeeva/mydocument.pdf")
159158

@@ -170,7 +169,7 @@ resp, err := resty.R().
170169
// * Fallback is plain text content type
171170
```
172171

173-
#### Sample PUT
172+
#### Sample PUT
174173
You can use various combinations of `PUT` method call like demonstrated for `POST`.
175174
```go
176175
// Note: This is one sample of PUT method usage, refer POST for more combination
@@ -179,7 +178,7 @@ You can use various combinations of `PUT` method call like demonstrated for `POS
179178
// No need to set auth token, error, if you have client level settings
180179
resp, err := resty.R().
181180
SetBody(Article{
182-
Title: "go-resty",
181+
Title: "go-resty",
183182
Content: "This is my article content, oh ya!",
184183
Author: "Jeevanandam M",
185184
Tags: []string{"article", "sample", "resty"},
@@ -189,7 +188,7 @@ resp, err := resty.R().
189188
Put("https://myapp.com/article/1234")
190189
```
191190

192-
#### Sample PATCH
191+
#### Sample PATCH
193192
You can use various combinations of `PATCH` method call like demonstrated for `POST`.
194193
```go
195194
// Note: This is one sample of PUT method usage, refer POST for more combination
@@ -246,7 +245,7 @@ resp, err := dclr().
246245
SetFileReader("profile_img", "test-img.png", bytes.NewReader(profileImgBytes)).
247246
SetFileReader("notes", "text-file.txt", bytes.NewReader(notesBytes)).
248247
SetFormData(map[string]string{
249-
"first_name": "Jeevanandam",
248+
"first_name": "Jeevanandam",
250249
"last_name": "M",
251250
}).
252251
Post(t"http://myapp.com/upload")
@@ -262,21 +261,21 @@ resp, err := resty.R().
262261
// Multiple files scenario
263262
resp, err := resty.R().
264263
SetFiles(map[string]string{
265-
"profile_img": "/Users/jeeva/test-img.png",
264+
"profile_img": "/Users/jeeva/test-img.png",
266265
"notes": "/Users/jeeva/text-file.txt",
267266
}).
268267
Post("http://myapp.com/upload")
269268

270269
// Multipart of form fields and files
271270
resp, err := resty.R().
272271
SetFiles(map[string]string{
273-
"profile_img": "/Users/jeeva/test-img.png",
272+
"profile_img": "/Users/jeeva/test-img.png",
274273
"notes": "/Users/jeeva/text-file.txt",
275274
}).
276275
SetFormData(map[string]string{
277-
"first_name": "Jeevanandam",
276+
"first_name": "Jeevanandam",
278277
"last_name": "M",
279-
"zip_code": "00001",
278+
"zip_code": "00001",
280279
"city": "my city",
281280
"access_token": "C6A79608-782F-4ED0-A11D-BD82FAD829CD",
282281
}).
@@ -289,17 +288,17 @@ resp, err := resty.R().
289288
// User Login
290289
resp, err := resty.R().
291290
SetFormData(map[string]string{
292-
"username": "jeeva",
291+
"username": "jeeva",
293292
"password": "mypass",
294293
}).
295294
Post("http://myapp.com/login")
296295

297296
// Followed by profile update
298297
resp, err := resty.R().
299298
SetFormData(map[string]string{
300-
"first_name": "Jeevanandam",
299+
"first_name": "Jeevanandam",
301300
"last_name": "M",
302-
"zip_code": "00001",
301+
"zip_code": "00001",
303302
"city": "new city update",
304303
}).
305304
Post("http://myapp.com/profile")
@@ -308,7 +307,7 @@ resp, err := resty.R().
308307
#### Save HTTP Response into File
309308
```go
310309
// Setting output directory path, If directory not exists then resty creates one!
311-
// This is optional one, if you're planning using absoule path in
310+
// This is optional one, if you're planning using absoule path in
312311
// `Request.SetOutput` and can used together.
313312
resty.SetOutputDirectory("/Users/jeeva/Downloads")
314313

@@ -327,7 +326,7 @@ _, err := resty.R().
327326
#### Request and Response Middleware
328327
Resty provides middleware ability to manipulate for Request and Response. It is more flexible than callback approach.
329328
```go
330-
// Registering Request Middleware
329+
// Registering Request Middleware
331330
resty.OnBeforeRequest(func(c *resty.Client, req *resty.Request) error {
332331
// Now you have access to Client and current Request object
333332
// manipulate it as per your need
@@ -351,7 +350,7 @@ Resty provides few ready to use redirect policy(s) also it supports multiple pol
351350
resty.SetRedirectPolicy(resty.FlexibleRedirectPolicy(15))
352351

353352
// Wanna multiple policies such as redirect count, domain name check, etc
354-
resty.SetRedirectPolicy(resty.FlexibleRedirectPolicy(20),
353+
resty.SetRedirectPolicy(resty.FlexibleRedirectPolicy(20),
355354
resty.DomainCheckRedirectPolicy("host1.com", "host2.org", "host3.net"))
356355
```
357356

@@ -375,7 +374,7 @@ type CustomRedirectPolicy struct {
375374

376375
func (c *CustomRedirectPolicy) Apply(req *http.Request, via []*http.Request) error {
377376
// Implement your logic here
378-
377+
379378
// return nil for continue redirect otherwise return error to stop/prevent redirect
380379
return nil
381380
}
@@ -431,7 +430,7 @@ resp, err := c.R().
431430
resty.SetRESTMode()
432431

433432
// HTTP mode
434-
resty.SetHTTPMode()
433+
resty.SetHTTPMode()
435434
```
436435

437436
#### Wanna Multiple Clients
@@ -527,7 +526,7 @@ resty releases versions according to [Semantic Versioning](http://semver.org)
527526

528527
`gopkg.in/resty.vX` points to appropriate tag versions; `X` denotes version number and it's a stable release. It's recommended to use version, for eg. `gopkg.in/resty.v0`. Development takes place at the master branch. Although the code in master should always compile and test successfully, it might break API's. We aim to maintain backwards compatibility, but API's and behaviour might be changed to fix a bug.
529528

530-
529+
531530
## Contributing
532531
Welcome! If you find any improvement or issue you want to fix, feel free to send a pull request, I like pull requests that include test cases for fix/enhancement. I have done my best to bring pretty good code coverage. Feel free to write tests.
533532

0 commit comments

Comments
 (0)