UtopiaSourceUtopiaControllerRespond

module Respond

A controller layer which provides a convenient way to respond to different requested content types. The order in which you add converters matters, as it determines how the incoming Accept: header is mapped, e.g. the first converter is also defined as matching the media range /.

Nested

Definitions

def process!(request, path)

Invokes super. If a response is generated, format it based on the Accept: header, unless the content type was already specified.

Implementation

def process!(request, path)
	if response = super
		headers = response[1]
		
		# Don't try to convert the response if a content type was explicitly specified.
		if headers[HTTP::CONTENT_TYPE]
			return response
		else
			return self.response_for(request, response)
		end
	end
end