Class: Stubby::Extensions::HTTP::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/stubby/extensions/http.rb

Direct Known Subclasses

SSLServer

Instance Method Summary collapse

Constructor Details

#initializeServer

Returns a new instance of Server.



189
190
191
# File 'lib/stubby/extensions/http.rb', line 189

def initialize
  @log = Logger.new(STDOUT)
end

Instance Method Details

#expand_rule(trigger, instruction, proto = 'http') ⇒ Object

blah.com => localhost:3000

>

blah.com => http-proxy://localhost:3000



203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/stubby/extensions/http.rb', line 203

def expand_rule(trigger, instruction, proto='http')
  u = URI.parse(instruction)
      
  (if u.scheme.nil?
    { trigger => "http-proxy://#{instruction}" }
  elsif u.scheme == "http"
    u.scheme = "http-proxy"
    { trigger => u.to_s }
  else
    { trigger => instruction }
  end).merge({
    "#{trigger.gsub(proto + "://", "dns://")}/a" => "dns-a://#{STUBBY_MASTER}"
  })
end

#restore!Object



222
223
224
# File 'lib/stubby/extensions/http.rb', line 222

def restore!
  # nil
end

#run!(session, options) ⇒ Object



193
194
195
196
197
198
# File 'lib/stubby/extensions/http.rb', line 193

def run!(session, options)
  return if options[:http] == false

  @session = session
  HTTPApp.run!(session)
end

#stop!Object



218
219
220
# File 'lib/stubby/extensions/http.rb', line 218

def stop!
  HTTPApp.quit!
end