Sha256: 82deb43fb73ab5e44fb99077e38648c9528099d89dc971628ac9e79d5c6767b4

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

module JSONAPIonify::Api
  module Base::AppBuilder

    def call(env)
      app.call(env)
    end

    private

    def app
      api = self
      Rack::Builder.new do
        use Rack::ShowExceptions
        use Rack::CommonLogger
        use Base::Reloader unless ENV['RACK_ENV'] == 'production'
        map "/docs" do
          run ->(env) {
            request    = JSONAPIonify::Api::Server::Request.new env
            if request.path_info.present?
              return [301, { 'location' => request.path.chomp(request.path_info) }, []]
            end
            response   = Rack::Response.new
            response.write api.documentation_output(request)
            response.finish
          }
        end
        map "/" do
          run JSONAPIonify::Api::Server.new(api)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsonapionify-0.0.1.pre lib/jsonapionify/api/base/app_builder.rb