Class: Propshaft::Server
- Inherits:
-
Object
- Object
- Propshaft::Server
- Defined in:
- lib/propshaft/server.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(assembly) ⇒ Server
constructor
A new instance of Server.
- #inspect ⇒ Object
Constructor Details
#initialize(assembly) ⇒ Server
Returns a new instance of Server.
5 6 7 |
# File 'lib/propshaft/server.rb', line 5 def initialize(assembly) @assembly = assembly end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/propshaft/server.rb', line 9 def call(env) path, digest = extract_path_and_digest(env) if (asset = @assembly.load_path.find(path)) && asset.fresh?(digest) compiled_content = @assembly.compilers.compile(asset) [ 200, { Rack::CONTENT_LENGTH => compiled_content.length.to_s, Rack::CONTENT_TYPE => asset.content_type.to_s, VARY => "Accept-Encoding", Rack::ETAG => asset.digest, Rack::CACHE_CONTROL => "public, max-age=31536000, immutable" }, [ compiled_content ] ] else [ 404, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "9" }, [ "Not found" ] ] end end |
#inspect ⇒ Object
31 32 33 |
# File 'lib/propshaft/server.rb', line 31 def inspect self.class.inspect end |