Class: Swagui::App
- Inherits:
-
Object
- Object
- Swagui::App
- Defined in:
- lib/swagui/app.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}, &blk) ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(app, options = {}, &blk) ⇒ App
Returns a new instance of App.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/swagui/app.rb', line 9 def initialize(app, ={}, &blk) @app = app @asset_handler = AssetHandler.new([:url]) @swagger_doc_handler = SwaggerDocHandler.new([:path], [:url]) if block_given? @asset_stack = Rack::Auth::Basic.new(@asset_handler, "Restricted Documentation", &blk) @swagger_doc_stack = Rack::Auth::Basic.new(@swagger_doc_handler, "Restricted Documentation", &blk) else @asset_stack = @asset_handler @swagger_doc_stack = @swagger_doc_handler end end |
Instance Method Details
#call(env) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/swagui/app.rb', line 23 def call(env) if @asset_handler.handles?(env) # for assets (css/js) files @asset_stack.call(env) elsif @swagger_doc_handler.handles?(env) # for swagger json files @swagger_doc_stack.call(env) else @app.call(env) end end |