Class: VersionCake::ResponseStrategy::HttpContentTypeStrategy

Inherits:
Base
  • Object
show all
Defined in:
lib/versioncake/response_strategy/http_content_type_strategy.rb

Instance Method Summary collapse

Methods inherited from Base

lookup, #version_key

Instance Method Details

#execute(context, _status, headers, _response) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/versioncake/response_strategy/http_content_type_strategy.rb', line 4

def execute(context, _status, headers, _response)
  return if headers['Content-Type'].nil?

  content_type = headers['Content-Type']
  content_type << ';' unless headers['Content-Type'].end_with?(';')

  headers['Content-Type'] = "#{content_type} #{version_key}=#{context.version.to_s}"
end