rack-action 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.
- data/lib/rack/action.rb +13 -1
- data/lib/rack/version.rb +1 -1
- data/rack-action.gemspec +1 -1
- metadata +3 -4
data/lib/rack/action.rb
CHANGED
@@ -109,6 +109,8 @@ module Rack
|
|
109
109
|
# @private
|
110
110
|
CONTENT_TYPE = 'Content-Type'.freeze
|
111
111
|
# @private
|
112
|
+
HTTP_ACCEPT = 'HTTP_ACCEPT'.freeze
|
113
|
+
# @private
|
112
114
|
TEXT_HTML = 'text/html'.freeze
|
113
115
|
# @private
|
114
116
|
APPLICATION_JSON = 'application/json'.freeze
|
@@ -146,6 +148,16 @@ module Rack
|
|
146
148
|
end
|
147
149
|
end
|
148
150
|
|
151
|
+
def format
|
152
|
+
if params[:format]
|
153
|
+
params[:format]
|
154
|
+
elsif env[HTTP_ACCEPT] == APPLICATION_JSON
|
155
|
+
"json"
|
156
|
+
else
|
157
|
+
"html"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
149
161
|
# This is the main method responsible for generating a Rack response.
|
150
162
|
# You typically won't need to override this method or call it directly.
|
151
163
|
# First this will run the before filters for this action.
|
@@ -247,7 +259,7 @@ module Rack
|
|
247
259
|
def log_call
|
248
260
|
if logger
|
249
261
|
logger.debug do
|
250
|
-
"#{self.class} #{request.env["REQUEST_METHOD"]} params: #{params.inspect}"
|
262
|
+
"#{self.class} #{request.env["REQUEST_METHOD"]} format: #{format.inspect}, params: #{params.inspect}"
|
251
263
|
end
|
252
264
|
end
|
253
265
|
end
|
data/lib/rack/version.rb
CHANGED
data/rack-action.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -70,11 +70,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.8.
|
73
|
+
rubygems_version: 1.8.25
|
74
74
|
signing_key:
|
75
75
|
specification_version: 3
|
76
76
|
summary: a small, simple framework for generating Rack responses
|
77
77
|
test_files:
|
78
78
|
- test/rack/action_test.rb
|
79
79
|
- test/rack_test.rb
|
80
|
-
has_rdoc:
|