Class: Roby::Interface::REST::Server::RackMiddleware Private

Inherits:
Object
  • Object
show all
Defined in:
lib/roby/interface/rest/server.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Intermediate Rack middleware used to inject the roby storage and interface objects that allow Helpers to function

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, interface, storage = {}, roby_execute: true) ⇒ RackMiddleware

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RackMiddleware.



90
91
92
93
94
95
# File 'lib/roby/interface/rest/server.rb', line 90

def initialize(api, interface, storage = {}, roby_execute: true)
    @api = api
    @interface = interface
    @storage = storage
    @roby_execute = roby_execute
end

Instance Attribute Details

#interfaceObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



88
89
90
# File 'lib/roby/interface/rest/server.rb', line 88

def interface
  @interface
end

#storageObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



88
89
90
# File 'lib/roby/interface/rest/server.rb', line 88

def storage
  @storage
end

Instance Method Details

#call(env) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/roby/interface/rest/server.rb', line 97

def call(env)
    env["roby.interface"] = interface
    env["roby.storage"] = storage

    if @roby_execute
        interface.app.execution_engine.execute do
            @api.call(env)
        end
    else
        @api.call(env)
    end
end