Class: VagrantPlugins::S3Auth::ExpandS3Urls
- Inherits:
-
Object
- Object
- VagrantPlugins::S3Auth::ExpandS3Urls
- Defined in:
- lib/vagrant-s3auth/middleware/expand_s3_urls.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, _) ⇒ ExpandS3Urls
constructor
A new instance of ExpandS3Urls.
Constructor Details
#initialize(app, _) ⇒ ExpandS3Urls
Returns a new instance of ExpandS3Urls.
6 7 8 |
# File 'lib/vagrant-s3auth/middleware/expand_s3_urls.rb', line 6 def initialize(app, _) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vagrant-s3auth/middleware/expand_s3_urls.rb', line 10 def call(env) env[:box_urls].map! do |url_string| url = URI(url_string) if url.scheme == 's3' bucket = url.host key = url.path[1..-1] raise Errors::MalformedShorthandURLError, url: url unless bucket && key next "http://s3-placeholder.amazonaws.com/#{bucket}/#{key}" end url_string end @app.call(env) end |