versioned-routes-rails 0.1.0 → 0.2.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/Gemfile.lock +1 -1
- data/README.md +6 -2
- data/lib/versioned_routes/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be1589161c8e9cf26731cfb9d3d4c0d04eaf3564d15a43ca2d77db7991691aff
|
4
|
+
data.tar.gz: a4ac74cc6726810af4cef4da1f79d4a62a8d88370d4e7749a425e2d72b0f8412
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dd0beb1aaa536275d0bd5db24b99826bd9677f7cc3384632f1bca541651eb87579a456d985a9de16c881a0db1715e8dc2211d15bf3e5d0579ac8bc304065951
|
7
|
+
data.tar.gz: 40986578d54c12136cda9a6f6b559aa75c9162647e80d1668da6a5594f23b715c372998c97379fa31effd17ea07ffd2f177ab13bcdfbc6616f1e1d264afc526a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -22,6 +22,8 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
+
`require 'versioned_routes'` in your `routes.rb` to load the `version` DSL.
|
26
|
+
|
25
27
|
Controllers must be namespaced as `VN::ThingController`, where `N` is the API version.
|
26
28
|
|
27
29
|
For example, let's define our V1 API as a set of `Message` resources, with some member actions. These will map to `V1::MessagesController`.
|
@@ -29,6 +31,8 @@ For example, let's define our V1 API as a set of `Message` resources, with some
|
|
29
31
|
Our V2 API will only change the logic of `V1::MessagesController#show`, so we'll only specify that action in the `version 2` block. Requests to `/api/v2/messages/:id` will be routed to `V2::MessagesController#show`, while all other `/api/v2/messages` requests will still be routed to `V1::MessagesController`.
|
30
32
|
|
31
33
|
```ruby
|
34
|
+
require 'versioned_routes'
|
35
|
+
|
32
36
|
Rails.application.routes.draw do
|
33
37
|
scope :api do
|
34
38
|
version 1 do
|
@@ -50,7 +54,7 @@ end
|
|
50
54
|
$ rake routes
|
51
55
|
```
|
52
56
|
|
53
|
-
|
57
|
+
<pre>
|
54
58
|
Prefix Verb URI Pattern Controller#Action
|
55
59
|
read_v1_message POST /api/v1/messages/:id/read(.:format) v1/messages#read {:format=>:json, :api_version=>1}
|
56
60
|
v1_messages GET /api/v1/messages(.:format) v1/messages#index {:format=>:json, :api_version=>1}
|
@@ -66,7 +70,7 @@ $ rake routes
|
|
66
70
|
PATCH /api/v2/messages/:id(.:format) v1/messages#update {:format=>:json, :api_version=>1}
|
67
71
|
PUT /api/v2/messages/:id(.:format) v1/messages#update {:format=>:json, :api_version=>1}
|
68
72
|
DELETE /api/v2/messages/:id(.:format) v1/messages#destroy {:format=>:json, :api_version=>1}
|
69
|
-
|
73
|
+
</pre>
|
70
74
|
|
71
75
|
## Development
|
72
76
|
|