lib/hyperdrive/endpoint.rb in hyperdrive-0.0.8 vs lib/hyperdrive/endpoint.rb in hyperdrive-0.0.9

- old
+ new

@@ -8,11 +8,11 @@ @request = Rack::Request.new(@env) @media_type = env['hyperdrive.media_type'] @params = env['hyperdrive.params'] @resource = env['hyperdrive.resource'] @headers = Hyperdrive::Values.default_headers.dup - @headers.merge!('Allow' => resource.allowed_methods, 'Content-Type' => @media_type) + @headers.merge!('Allow' => resource.allowed_methods.join(', '), 'Content-Type' => @media_type) response.finish end private @@ -42,15 +42,17 @@ case body when Array, Hash if json? MultiJson.dump(body) else - env['rack.errors'] << "ENDPOINT: Can't serialize response automatically" + env.logger.error "ENDPOINT: Can't serialize response automatically" + raise Errors::NoResponse.new end when String body else + env.logger.debug "ENDPOINT: Coerceing response to string. Probably not what you want" body.to_s end end def self.error(status, message) @@ -73,9 +75,9 @@ body = '' if env['REQUEST_METHOD'] == 'DELETE' body end def self.response - ::Rack::Response.new(body, status, headers) + ::Rack::Response.new(render(body), status, headers) end end end