Method: MiddleSquid::Adapter#handle

Defined in:
lib/middle_squid/adapter.rb

#handle(url, extras = []) ⇒ Object

Execute the user handler (see #handler) and calls #output.

Parameters:

  • string representation of the url to be processed

  • (defaults to: [])

    extra data to pass to the user’s handler

Raises:



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/middle_squid/adapter.rb', line 22

def handle(url, extras = [])
  uri = MiddleSquid::URI.parse url
  raise InvalidURIError, "invalid URL received: '#{url}'" if !uri || !uri.host

  action, options = catch :action do
    @handler.call uri, extras
    throw :action, [:accept, {}]
  end

  output action, options
end