respondo 0.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +179 -0
- data/README.md +419 -188
- data/lib/respondo/configuration.rb +6 -0
- data/lib/respondo/controller_helpers.rb +272 -67
- data/lib/respondo/pagination.rb +141 -83
- data/lib/respondo/response_builder.rb +48 -19
- data/lib/respondo/version.rb +1 -1
- data/lib/respondo.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f627c02a80d4eb8ab106714e2739d38b17545a93d1772e052497850c8a56f437
|
|
4
|
+
data.tar.gz: 8f078c4540d8182fc59ccdc8c539b29835ccb9f7cf5d781b2ae389e0a9c04461
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4677d2d32eaa9441032829a6414cd81d24d831b61ce45e0fd3586c4d804745d9307a1bc375b280b0801d53812b6accb656ae28ac1c36dc858befa51c3098b2aa
|
|
7
|
+
data.tar.gz: 937d964de71ac65cd5d13df236cf74012b390cee914c13b8078a653db7d7a2273037593fad1981df41a59280e3cba677f5ede00ea6992b07058b90a5456645f6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,184 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.0.0] — Full HTTP Coverage
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
#### Pagination API completely redesigned
|
|
8
|
+
The old approach auto-detected Kaminari, Pagy, and WillPaginate collections and
|
|
9
|
+
extracted pagination metadata silently. This was over-engineered — Respondo is a
|
|
10
|
+
**response formatter**, not a pagination library.
|
|
11
|
+
|
|
12
|
+
**Before (1.x):**
|
|
13
|
+
```ruby
|
|
14
|
+
# Kaminari / WillPaginate — auto-detected from collection
|
|
15
|
+
render_ok(data: @users)
|
|
16
|
+
|
|
17
|
+
# Pagy — required a separate pagy: argument
|
|
18
|
+
render_ok(data: @users, pagy: @pagy)
|
|
19
|
+
|
|
20
|
+
# Suppress pagination
|
|
21
|
+
render_ok(data: @users, pagination: false)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**After (2.x):**
|
|
25
|
+
```ruby
|
|
26
|
+
# All libraries — you build the hash, Respondo places it in meta
|
|
27
|
+
render_ok(
|
|
28
|
+
data: @users,
|
|
29
|
+
pagination: {
|
|
30
|
+
current_page: @users.current_page,
|
|
31
|
+
per_page: @users.limit_value, # Kaminari
|
|
32
|
+
total_pages: @users.total_pages,
|
|
33
|
+
total_count: @users.total_count,
|
|
34
|
+
next_page: @users.next_page,
|
|
35
|
+
prev_page: @users.prev_page
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# No pagination — just omit the param
|
|
40
|
+
render_ok(data: @user)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Why:** The caller already has the paginated data in hand. Building the hash
|
|
44
|
+
themselves is one extra step, but it makes the behavior completely explicit,
|
|
45
|
+
works with any library (or no library), and removes a hidden dependency from
|
|
46
|
+
the gem's internals.
|
|
47
|
+
|
|
48
|
+
**Migration steps:**
|
|
49
|
+
1. Delete any `pagy:` arguments — replace with `pagination: { ... }` hash
|
|
50
|
+
2. Delete any `pagination: false` arguments — just omit `pagination:` instead
|
|
51
|
+
3. Remove `pagination.rb` from your gem if you vendored it
|
|
52
|
+
|
|
53
|
+
#### `render_success` signature change
|
|
54
|
+
- `pagy:` parameter removed
|
|
55
|
+
- `pagination:` parameter type changed from `Boolean` → `Hash | nil`
|
|
56
|
+
|
|
57
|
+
**Before:** `render_success(data:, message:, meta:, code:, pagy:, pagination: Boolean, status:)`
|
|
58
|
+
**After:** `render_success(data:, message:, meta:, code:, pagination: Hash | nil, status:)`
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### Added
|
|
63
|
+
|
|
64
|
+
#### 1xx — Informational helpers (all new)
|
|
65
|
+
These return a JSON body for API consistency. Note that 1xx responses are
|
|
66
|
+
protocol-level and most HTTP clients will not receive them as normal responses.
|
|
67
|
+
|
|
68
|
+
| Helper | Code |
|
|
69
|
+
|--------|------|
|
|
70
|
+
| `render_continue` | 100 |
|
|
71
|
+
| `render_switching_protocols` | 101 |
|
|
72
|
+
| `render_processing` | 102 |
|
|
73
|
+
| `render_early_hints` | 103 |
|
|
74
|
+
|
|
75
|
+
#### 2xx — Additional success helpers
|
|
76
|
+
| Helper | Code |
|
|
77
|
+
|--------|------|
|
|
78
|
+
| `render_non_authoritative` | 203 |
|
|
79
|
+
| `render_reset_content` | 205 |
|
|
80
|
+
| `render_already_reported` | 208 |
|
|
81
|
+
| `render_im_used` | 226 |
|
|
82
|
+
|
|
83
|
+
#### 3xx — Redirect helpers (all new)
|
|
84
|
+
Pass the target URL via `meta: { redirect_url: "..." }`.
|
|
85
|
+
|
|
86
|
+
| Helper | Code |
|
|
87
|
+
|--------|------|
|
|
88
|
+
| `render_multiple_choices` | 300 |
|
|
89
|
+
| `render_moved_permanently` | 301 |
|
|
90
|
+
| `render_found` | 302 |
|
|
91
|
+
| `render_see_other` | 303 |
|
|
92
|
+
| `render_not_modified` | 304 |
|
|
93
|
+
| `render_temporary_redirect` | 307 |
|
|
94
|
+
| `render_permanent_redirect` | 308 |
|
|
95
|
+
|
|
96
|
+
#### 4xx — Additional client error helpers
|
|
97
|
+
| Helper | Code |
|
|
98
|
+
|--------|------|
|
|
99
|
+
| `render_proxy_auth_required` | 407 |
|
|
100
|
+
| `render_length_required` | 411 |
|
|
101
|
+
| `render_payload_too_large` | 413 |
|
|
102
|
+
| `render_uri_too_long` | 414 |
|
|
103
|
+
| `render_range_not_satisfiable` | 416 |
|
|
104
|
+
| `render_expectation_failed` | 417 |
|
|
105
|
+
| `render_im_a_teapot` | 418 |
|
|
106
|
+
| `render_misdirected_request` | 421 |
|
|
107
|
+
| `render_failed_dependency` | 424 |
|
|
108
|
+
| `render_too_early` | 425 |
|
|
109
|
+
| `render_upgrade_required` | 426 |
|
|
110
|
+
| `render_precondition_required` | 428 |
|
|
111
|
+
| `render_request_header_fields_too_large` | 431 |
|
|
112
|
+
| `render_unavailable_for_legal_reasons` | 451 |
|
|
113
|
+
|
|
114
|
+
#### 5xx — Additional server error helpers
|
|
115
|
+
| Helper | Code |
|
|
116
|
+
|--------|------|
|
|
117
|
+
| `render_http_version_not_supported` | 505 |
|
|
118
|
+
| `render_variant_also_negotiates` | 506 |
|
|
119
|
+
| `render_insufficient_storage` | 507 |
|
|
120
|
+
| `render_loop_detected` | 508 |
|
|
121
|
+
| `render_not_extended` | 510 |
|
|
122
|
+
| `render_network_authentication_required` | 511 |
|
|
123
|
+
|
|
124
|
+
#### `pagination:` on all 2xx and 3xx helpers
|
|
125
|
+
Previously only `render_ok` exposed a pagination parameter. Now every 2xx and
|
|
126
|
+
3xx helper accepts `pagination: Hash | nil` so you can include pagination meta
|
|
127
|
+
from any success response type, not just 200.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### Removed
|
|
132
|
+
|
|
133
|
+
- `pagination.rb` — entire file deleted. Auto-detection of Kaminari, Pagy, and
|
|
134
|
+
WillPaginate is no longer part of the gem. Respondo has zero pagination
|
|
135
|
+
library dependencies.
|
|
136
|
+
- `pagy:` parameter from `render_success` and `render_ok`
|
|
137
|
+
- `pagination: Boolean` flag — no longer needed since passing `nil` (the default)
|
|
138
|
+
simply omits the key from meta
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### Stats
|
|
143
|
+
|
|
144
|
+
| | v1.0.0 | v2.0.0 |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| Total helpers | 7 | 57 |
|
|
147
|
+
| HTTP codes covered | 13 | 52 |
|
|
148
|
+
| Files | 7 | 6 (pagination.rb removed) |
|
|
149
|
+
| Pagination gem dependencies | 3 (optional) | 0 |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## [1.0.0] — Production Ready
|
|
154
|
+
|
|
155
|
+
### Breaking Changes
|
|
156
|
+
- `render_error` and all error helpers (`render_bad_request`, `render_unauthorized`,
|
|
157
|
+
`render_forbidden`, `render_not_found`, etc.) — removed `status` as a public
|
|
158
|
+
parameter; status is now derived internally and can no longer be overridden by callers
|
|
159
|
+
- All error helpers now accept `meta: {}` — allows per-call meta injection
|
|
160
|
+
(previously only `render_success` and success helpers supported this)
|
|
161
|
+
|
|
162
|
+
### Added
|
|
163
|
+
- `meta: {}` parameter on all error helpers — pass per-request meta such as
|
|
164
|
+
`api_version`, `env`, `region` directly at the call site
|
|
165
|
+
- `config.default_meta` — static key-value pairs merged into every response's
|
|
166
|
+
meta block automatically (e.g. `{ api_version: "v1", platform: "api" }`)
|
|
167
|
+
- Deterministic meta key ordering — `request_id` → `timestamp` → `default_meta`
|
|
168
|
+
→ caller `meta` → `code` → `status`
|
|
169
|
+
|
|
170
|
+
### Fixed
|
|
171
|
+
- Error helper `code:` values were strings (e.g. `"404"`) while success helpers
|
|
172
|
+
used integers — all codes are now consistently integers across all helpers
|
|
173
|
+
- Trailing commas removed from `render_service_unavailable` and
|
|
174
|
+
`render_gateway_timeout` signatures
|
|
175
|
+
- `render_no_content` had mismatched `status: :ok` (200) with `code: 204` in
|
|
176
|
+
meta — now consistent
|
|
177
|
+
- Caller-supplied `meta` could previously override system fields (`timestamp`,
|
|
178
|
+
`request_id`) — system fields are now always authoritative
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
3
182
|
## [0.1.0] — Initial Release
|
|
4
183
|
|
|
5
184
|
### Added
|