Class: Orange::Middleware::AbstractFormat

Inherits:
Base show all
Defined in:
lib/orange-core/middleware/abstract_format.rb

Overview

This is an adapted Orange version of mynyml’s rack-abstract-format available at github.com/mynyml/rack-abstract-format

Instance Method Summary collapse

Methods inherited from Base

#call, #initialize, #inspect, #orange, #pass, #recapture

Constructor Details

This class inherits a constructor from Orange::Middleware::Base

Instance Method Details

#init(opts = {}) ⇒ Object



8
9
# File 'lib/orange-core/middleware/abstract_format.rb', line 8

def init(opts = {})
end

#packet_call(packet) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/orange-core/middleware/abstract_format.rb', line 11

def packet_call(packet)
  path_info = packet['route.path'] || packet.env['PATH_INFO']
  path = Pathname(path_info)
  packet['route.path'] = path.to_s.sub(/#{path.extname}$/,'') if Rack::Mime::MIME_TYPES.include?(path.extname)
  packet.env['HTTP_ACCEPT'] = concat(packet.env['HTTP_ACCEPT'], Rack::Mime.mime_type(path.extname))
  
  pass packet
end