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



42
43
44
45
46
47
48
# File 'lib/utopia/controller/respond.rb', line 42

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



38
39
40
# File 'lib/utopia/controller/respond.rb', line 38

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