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.
@@ -1,3 +1,7 @@
1
+ == 0.8.2 2009-08-03
2
+
3
+ * Better content negotiation
4
+
1
5
  == 0.8.1 2009-08-03
2
6
 
3
7
  * Link headers on the described_routes ResourceTemplate(s) metadata served by the middleware
@@ -2,5 +2,5 @@ require 'resource_template'
2
2
 
3
3
  module DescribedRoutes
4
4
  # rubygem version
5
- VERSION = "0.8.1"
5
+ VERSION = "0.8.2"
6
6
  end
@@ -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
- Rack::RespondTo.media_types = %w(.text .json .yaml .xml).map{|format| Rack::Mime::MIME_TYPES[format]}
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|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: described_routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Burrows