Skip to content

Commit 319274b

Browse files
author
William Tsai
committed
Update readme description
1 parent a020c2d commit 319274b

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,18 @@ end
5757

5858
### Success Response
5959

60-
The success response is used when the request is success.
60+
The success response is used when the request is success. The response body is a hash with a `data` key.
6161

6262
```ruby
6363
# in controller actions
6464
data = { a: 1, b: 2 }
6565
return success_response(data) if success?
6666
```
6767

68+
> response status: 200
69+
> response body:
70+
6871
```json
69-
// response status: 200
70-
// response body:
7172
{
7273
"data": {
7374
"a": 1,
@@ -85,9 +86,10 @@ The error response is used when the request is not valid. Therefore, you need to
8586
return error_response(:bad_request_1) if failed?
8687
```
8788

89+
> response status: 400
90+
> response body:
91+
8892
```json
89-
// response status: 400
90-
// response body:
9193
{
9294
"error_code": 400_001,
9395
"error_message": "bad request 1",
@@ -102,9 +104,10 @@ You can also provide your custom error message and error data. If error data is
102104
return error_response(:bad_request_1, 'no required data', { a: 1, b: 2 }) if failed?
103105
```
104106

107+
> response status: 400
108+
> response body:
109+
105110
```json
106-
// response status: 400
107-
// response body:
108111
{
109112
"error_code": 400_001,
110113
"error_message": "bad request 1: no required data",
@@ -140,9 +143,10 @@ ErrorResponse.to_hash(:bad_request_1)
140143

141144
gives you
142145

146+
> response status: 400
147+
> response body:
148+
143149
```json
144-
// response status: 400
145-
// response body:
146150
{
147151
"error_code": 400_001,
148152
"error_message": "bad request 1",

0 commit comments

Comments
 (0)