grape_ape_rails 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grape_ape_rails/api.rb +1 -0
- data/lib/grape_ape_rails/handlers/path_versioning.rb +27 -0
- data/lib/grape_ape_rails/version.rb +1 -1
- data/lib/tasks/routes.rake +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1240d678239c0a950d300e1156f6016e37c87ad
|
4
|
+
data.tar.gz: 883a54b7f9f0898db02a7143a4c032a72470e08d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5861891416f4090aaccc2eb37d4862d7f62ed5042eecdcb8ac4147be31ed93901bb0ad333152ff1790a8063ab9722c975c7b761fe33831fc74665a4336e002b3
|
7
|
+
data.tar.gz: 633a04ae35c65fdc5d00612444bc5d82c691acaae03971bce2afdd3a9ae0975c9bbaf3e4ad3bbda6ca601609cbfdf04b40789507e5339ff5c4c153c2f9a55641
|
data/lib/grape_ape_rails/api.rb
CHANGED
@@ -6,6 +6,7 @@ require 'hashie-forbidden_attributes' if defined?(::Rails)
|
|
6
6
|
require 'http_accept_language'
|
7
7
|
require 'grape_ape_rails/base'
|
8
8
|
require 'grape_ape_rails/handlers/header_versioning'
|
9
|
+
require 'grape_ape_rails/handlers/path_versioning'
|
9
10
|
require 'grape_ape_rails/handlers/rails_logging'
|
10
11
|
|
11
12
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module GrapeApeRails
|
2
|
+
module Handlers
|
3
|
+
module PathVersioning
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
gar_resource = self.name.split('::').last.underscore
|
8
|
+
gar_version = self.name.split('::')[-2].underscore.gsub('_','.')
|
9
|
+
cascades = GrapeApeRails::API.api_version_cascades_map
|
10
|
+
gar_version = cascades[gar_version] if cascades[gar_version].present?
|
11
|
+
# gar_appname = GrapeApeRails.configuration.app_name
|
12
|
+
# gar_organization = GrapeApeRails.configuration.organization_name
|
13
|
+
version gar_version, using: :path
|
14
|
+
|
15
|
+
before do
|
16
|
+
req = Rack::Request.new(env)
|
17
|
+
api_key = version ? GrapeApeRails::API.api_keys_map[version] : nil
|
18
|
+
if api_key.nil?
|
19
|
+
msg = "Cannot determine API version from header info."
|
20
|
+
error!({ code: "UNAUTHORIZED", message: msg}, 401)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/tasks/routes.rake
CHANGED
@@ -6,7 +6,8 @@ namespace :api do
|
|
6
6
|
API::Base.routes.each do |api|
|
7
7
|
method = api.route_method.ljust(10)
|
8
8
|
version = (api.route_version || '').ljust(15)
|
9
|
-
path = api.route_path
|
9
|
+
path = api.route_path
|
10
|
+
path = path.gsub("/:version", "/#{version.rstrip}") if version
|
10
11
|
puts " #{method} #{version} #{path}"
|
11
12
|
end
|
12
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape_ape_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt E. Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -385,6 +385,7 @@ files:
|
|
385
385
|
- lib/grape_ape_rails/handlers/formatters.rb
|
386
386
|
- lib/grape_ape_rails/handlers/header_versioning.rb
|
387
387
|
- lib/grape_ape_rails/handlers/locale.rb
|
388
|
+
- lib/grape_ape_rails/handlers/path_versioning.rb
|
388
389
|
- lib/grape_ape_rails/handlers/rails_logging.rb
|
389
390
|
- lib/grape_ape_rails/handlers/responses.rb
|
390
391
|
- lib/grape_ape_rails/railtie.rb
|