Class: Helios::Backend
- Inherits:
-
Rack::Builder
- Object
- Rack::Builder
- Helios::Backend
- Defined in:
- lib/helios/backend.rb
Defined Under Namespace
Classes: Data, InAppPurchase, Newsstand, Passbook, PushNotification
Constant Summary collapse
- DEFAULT_PATHS =
{ data: '/' }
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(*args, &block) ⇒ Backend
constructor
A new instance of Backend.
Constructor Details
#initialize(*args, &block) ⇒ Backend
Returns a new instance of Backend.
11 12 13 14 15 16 17 18 |
# File 'lib/helios/backend.rb', line 11 def initialize(*args, &block) raise ArgumentError, "Missing block" unless block_given? super(&nil) @services = {} instance_eval(&block) end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/helios/backend.rb', line 20 def call(env) return super(env) unless env["REQUEST_METHOD"] == "OPTIONS" and env["REQUEST_PATH"] == "/" links = [] @services.each do |path, middleware| links << %{<#{path}>; rel="#{middleware}"} end [206, {"Link" => links.join("\n")}, []] end |