Module: Apish
- Defined in:
- lib/apish.rb,
lib/apish/version.rb,
lib/apish/configuration.rb,
lib/generators/apish/endpoint/endpoint_generator.rb
Overview
require ‘apish/railtie’ if defined?( Rails )
Defined Under Namespace
Modules: Controller, Error, Responder
Classes: ApiVersion, Configuration, EndpointGenerator, FormatResolver
Constant Summary
collapse
- VERSION =
"0.11.0"
Class Method Summary
collapse
Class Method Details
.configuration ⇒ Object
13
14
15
|
# File 'lib/apish.rb', line 13
def self.configuration
@configuration ||= Configuration.new
end
|
17
18
19
|
# File 'lib/apish.rb', line 17
def self.configure
yield(configuration) if block_given?
end
|
.register_custom_mime_types ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/apish.rb', line 21
def self.register_custom_mime_types
dir = File.join( Rails.root, 'app', 'controllers', 'api' )
Dir.glob( "#{dir}/v*" ) do |d|
version = d[/(v\d+)$/, 1]
types = %w( json xml ).collect do |wire_format|
"api_#{version}_#{wire_format}"
end
types.each do |type|
mime_type = ["application/vnd.#{Apish.configuration.mime_types_base}",
type.split( '_' )[1..2].join( '+' )].join( '-' )
next if Mime.const_defined?( type.upcase )
Mime::Type.register mime_type, type.to_sym
end
end
end
|