Module: Utopia::Controller::Respond
- Defined in:
- lib/utopia/controller/respond.rb
Overview
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 /.
Defined Under Namespace
Modules: ClassMethods, Converter, Passthrough Classes: Responder
Class Method Summary collapse
Instance Method Summary collapse
-
#process!(request, path) ⇒ Object
Invokes super.
Class Method Details
.prepended(base) ⇒ Object
30 31 32 |
# File 'lib/utopia/controller/respond.rb', line 30 def self.prepended(base) base.extend(ClassMethods) end |
Instance Method Details
#process!(request, path) ⇒ Object
Invokes super. If a response is generated, format it based on the Accept: header, unless the content type was already specified.
171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/utopia/controller/respond.rb', line 171 def process!(request, path) if response = super headers = response[1] # Don't try to convert the response if a content type was explicitly specified. unless headers[Rack::CONTENT_TYPE] response = self.class.response_for(self, request, path, response) end response end end |