Class: Wayfarer::Middleware::UriParser

Inherits:
Object
  • Object
show all
Extended by:
Base
Defined in:
lib/wayfarer/middleware/uri_parser.rb

Defined Under Namespace

Modules: API

Constant Summary

Constants included from Base

Base::API_MODULE

Instance Method Summary collapse

Methods included from Base

api

Instance Method Details

#call(task) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/wayfarer/middleware/uri_parser.rb', line 18

def call(task)
  return (yield if block_given?) if task[:uri]

  begin
    task[:uri] = Addressable::URI.parse(task.url)
  rescue Addressable::URI::InvalidURIError => e
    return log(:invalid, task, message: e.message)
  end

  yield if block_given?
end