Class: Soybean::StaticServer
- Inherits:
-
Rack::Static
- Object
- Rack::Static
- Soybean::StaticServer
- Defined in:
- lib/soybean/static_server.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
Instance Method Summary collapse
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
3 4 5 |
# File 'lib/soybean/static_server.rb', line 3 def cache @cache end |
Instance Method Details
#call(env) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/soybean/static_server.rb', line 5 def call(env) path = env["PATH_INFO"] unless @urls.kind_of? Hash can_serve = @urls.any? { |url| path.index(url) == 0 } else can_serve = @urls.key? path end if can_serve env["PATH_INFO"] = @urls[path] if @urls.kind_of? Hash @file_server.call(env) else @app.call(env) end end |
#rewrite(env) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/soybean/static_server.rb', line 22 def rewrite(env) doc = Nokogiri.XML File.read(env["PATH_INFO"]) address = d.search('definitions/service/port/:first').first address['location'] = "#{env['SERVER_NAME']}:#{env['SERVER_PORT']}/#{env['soybean.service.endpoint']}" @cache[env["PATH_INFO"]] = doc end |