def call(env)
req = Rack::Request.new(env)
if cmd = req.params['command']
@command = cmd
@selection = req.params['type'] if req.params['type']
options = {}
case @selection
when 'least_loaded', 'random', 'all', 'rr'
options[:selector] = @selection
else
options[:target] = @selection
end
@mapper.request(cmd, req.params['payload'], options) do |response, responsejob|
env['async.callback'].call [200, {'Content-Type' => 'text/html'}, [layout(ul(response, responsejob))]]
end
AsyncResponse
else
[200, {'Content-Type' => 'text/html'}, layout]
end
end