Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
abemedia committed Apr 10, 2017
1 parent 8d94cdd commit 5eeeb37
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/less/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def initialize
@environment.native('fs', FS)
@environment.native('url', Url)
@environment.native('http', Http)
@environment.native('request', Request)
end

def require(module_id)
Expand Down Expand Up @@ -229,5 +230,21 @@ def on(event, callback)

end

module Request # :nodoc:
def self.get(options, callback)
err = nil
begin
uri = URI(options[:uri])
response = Net::HTTP.get_response(uri)
callback.call(nil, { statusCode: response.code.to_i }, response.body)
rescue => e
err = e.message
ensure
ret = Http::HttpGetResult.new(err)
end
ret
end
end

end
end

0 comments on commit 5eeeb37

Please sign in to comment.