Class: EdgeRack::Middleware
- Inherits:
-
Object
- Object
- EdgeRack::Middleware
- Defined in:
- lib/edge_rack/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/edge_rack/middleware.rb', line 4 def initialize(app, ={}) @app = app @options = { project_path: Dir.pwd, project_name: Pathname.new(Dir.pwd).basename, host: "http://localhost" }.merge() @kind = "rack" if defined?(Rails) @paths = { css: Rails.application.config.assets[:paths], sass: (Rails.application.config.sass[:load_paths] rescue []), less: (Rails.application.config.less[:paths] rescue []) } @kind = "rails" end params = { project_path: @options[:project_path], project_name: @options[:project_name], project_kind: @kind } if defined?(Rails) params[:load_paths] = ActiveSupport::JSON.encode(@paths) end # Thread.new do # Net::HTTP.post_form( # URI.parse('http://localhost:48626/project'), # params # ) # end end |
Instance Method Details
#call(env) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/edge_rack/middleware.rb', line 43 def call(env) @env = env @status, @headers, @response = @app.call(env) if is_edge_compatible_response? update_response! update_content_length! end [@status, @headers, @response] end |