Module: Utopia::Controller::Respond::Handlers::JSON

Defined in:
lib/utopia/controller/respond.rb

Constant Summary collapse

APPLICATION_JSON =
HTTP::Accept::ContentType.new('application', 'json').freeze

Class Method Summary collapse

Class Method Details

.call(context, request, media_range, object, **options) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/utopia/controller/respond.rb', line 25

def self.call(context, request, media_range, object, **options)
	if version = media_range.parameters['version']
		options[:version] = version.to_s
	end
	
	context.succeed! content: object.to_json(options), type: APPLICATION_JSON
end

.split(*arguments) ⇒ Object



21
22
23
# File 'lib/utopia/controller/respond.rb', line 21

def self.split(*arguments)
	APPLICATION_JSON.split(*arguments)
end