class WebFetch::Server
Web server that accepts requests to gather and retrieve external HTTP requests
Attributes
storage[R]
Public Instance Methods
post_init()
click to toggle source
Calls superclass method
# File lib/web_fetch/server.rb, line 12 def post_init super @router = Router.new @storage = WebFetch::Storage.create no_environment_strings end
process_http_request()
click to toggle source
# File lib/web_fetch/server.rb, line 20 def process_http_request resource = @router.route(@http_request_uri, request_params) response = EM::DelegatedHttpResponse.new(self) default_headers(response) outcome(resource, response) end
Private Instance Methods
immediate?(command)
click to toggle source
# File lib/web_fetch/server.rb, line 30 def immediate?(command) %w[gather root].include?(command) end
outcome(resource, response)
click to toggle source
# File lib/web_fetch/server.rb, line 34 def outcome(resource, response) command = resource[:command] Logger.debug(command) return respond_immediately(resource, response) if immediate?(command) return pending(resource, response) if resource[:request][:pending] succeeded = resource[:request][:response][:success] return succeed(resource, response) if succeeded fail_(resource, response) end