described_routes 0.8.1 → 0.8.2
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/History.txt +4 -0
- data/lib/described_routes.rb +1 -1
- data/lib/described_routes/middleware/base.rb +10 -2
- metadata +1 -1
data/History.txt
CHANGED
data/lib/described_routes.rb
CHANGED
@@ -100,15 +100,23 @@ module DescribedRoutes
|
|
100
100
|
else
|
101
101
|
rel = "self" # this is the site ResourceTemplates description
|
102
102
|
target = @resource_templates
|
103
|
-
end
|
103
|
+
end
|
104
104
|
expanded = target.partial_expand(req.GET)
|
105
|
+
|
105
106
|
Rack::RespondTo.env = req.env
|
106
107
|
if format
|
107
108
|
# Format extension overrides any accept header
|
108
109
|
Rack::RespondTo.media_types = [Rack::Mime::MIME_TYPES[format]]
|
109
110
|
else
|
110
111
|
# Supported formats, .text preferred. No html yet!
|
111
|
-
|
112
|
+
supported_media_types = %w(.text .json .yaml .xml).map{|format| Rack::Mime::MIME_TYPES[format]}
|
113
|
+
# not sure why this is needed - thought Rack::RespondTo would choose for us
|
114
|
+
http_accept = req.env['HTTP_ACCEPT']
|
115
|
+
if supported_media_types.grep(http_accept).empty?
|
116
|
+
Rack::RespondTo.media_types = supported_media_types
|
117
|
+
else
|
118
|
+
Rack::RespondTo.media_types = [http_accept]
|
119
|
+
end
|
112
120
|
end
|
113
121
|
|
114
122
|
body = respond_to do |format|
|