class Superbot::Web
Constants
- DEFAULT_OPTIONS
Public Class Methods
new(teleport_options = {})
click to toggle source
# File lib/superbot/web.rb, line 11 def initialize(teleport_options = {}) @sinatra = Sinatra.new @sinatra.set :bind, ENV.fetch('SUPERBOT_BIND_ADDRESS', '127.0.0.1') @sinatra.set :silent_sinatra, true @sinatra.set :silent_webrick, true @sinatra.set :silent_access_log, false @sinatra.server_settings[:Silent] = true @sinatra.set :teleport_options, DEFAULT_OPTIONS.merge(teleport_options) @sinatra.set :webdriver_url, Superbot.webdriver_endpoint(@sinatra.settings.teleport_options[:webdriver_type]) @sinatra.before do headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS' headers['Access-Control-Allow-Origin'] = '*' headers['Access-Control-Allow-Headers'] = 'accept, authorization, origin' end @sinatra.options '*' do response.headers['Allow'] = 'HEAD,GET,PUT,DELETE,OPTIONS,POST' response.headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Cache-Control, Accept' end @sinatra.get "/__superbot/v1/ping" do "PONG" end @sinatra.register Superbot::Teleport::Web if defined?(Superbot::Teleport::Web) @sinatra.register Superbot::Cloud::Web if defined?(Superbot::Cloud::Web) @sinatra.register Superbot::Convert::Web if defined?(Superbot::Convert::Web) end
run!(teleport_options = {})
click to toggle source
# File lib/superbot/web.rb, line 42 def self.run!(teleport_options = {}) new(teleport_options).tap(&:run!) end
Public Instance Methods
quit!()
click to toggle source
# File lib/superbot/web.rb, line 66 def quit! @sinatra&.quit! end
run!()
click to toggle source
# File lib/superbot/web.rb, line 50 def run! @sinatra.run! end
run_async!()
click to toggle source
# File lib/superbot/web.rb, line 46 def run_async! @sinatra.run_async! end
run_async_after_running!()
click to toggle source
# File lib/superbot/web.rb, line 54 def run_async_after_running! Thread.new do @sinatra.run! end loop do break if @sinatra.running? sleep 0.001 end end