Class: RubyBuildInfo::Middleware
- Inherits:
-
Object
- Object
- RubyBuildInfo::Middleware
- Defined in:
- lib/ruby_build_info/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.
5 6 7 8 9 |
# File 'lib/ruby_build_info/middleware.rb', line 5 def initialize(app, = {}) @app = app @file_paths = [:file_paths] @token = [:token] end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby_build_info/middleware.rb', line 11 def call(env) if env['PATH_INFO'] == '/build_info' @env = env return @app.call(env) unless token_valid? @build_info = {} @build_info[:git] = git_revision unless git_revision.empty? read_file_paths rails_info @build_info[:gems] = bundle_show output = JSON.pretty_generate(@build_info) [200, {'Content-Type' => 'application/json'}, [output]] else @app.call(env) end end |