Sha256: 56b97c5743e8e158bafbc910d1aa182417bd51e3b4bafd4fa45b464b875b376b
Contents?: true
Size: 891 Bytes
Versions: 1
Compression:
Stored size: 891 Bytes
Contents
require "rack/file" require "rack/utils" module SwaggerUiWrapper module Rack class MiddleWare def initialize(app, options) @app = app @api_url_base = options[:api_url_base] @path = options[:path] || '/swagger/' swagger_path = File.expand_path('../../../vendor/assets', File.dirname(__FILE__)) @swagger_assets_handler = ::Rack::Static.new @app, root: swagger_path, urls: ['/swagger'], index: 'index.html' end def call(env) if env['REQUEST_PATH'] && env['REQUEST_PATH'].start_with?(@path) _env = env.merge("QUERY_STRING" => "url=http://localhost:9292/v1/swagger_doc") @swagger_assets_handler.call(_env) else @app.call(env) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
efigence-swagger_ui_wrapper-0.0.6 | lib/swagger_ui_wrapper/rack/middleware.rb |