Sha256: cb965141caa5b8a5af8a16f4da7085d0061ad46f36fd11ea8b7522cc95bb602e

Contents?: true

Size: 809 Bytes

Versions: 6

Compression:

Stored size: 809 Bytes

Contents

require 'tomograph'
require 'esplanade/request'
require 'esplanade/response'

module Esplanade
  class DangerousMiddleware
    def initialize(
      app,
      prefix: Esplanade.configuration.prefix,
      apib_path: Esplanade.configuration.apib_path,
      drafter_yaml_path: Esplanade.configuration.drafter_yaml_path
    )
      @app = app
      @documentation = Tomograph::Tomogram.new(
        prefix: prefix,
        apib_path: apib_path,
        drafter_yaml_path: drafter_yaml_path
      )
    end

    def call(env)
      request = Esplanade::Request.new(@documentation, env)
      request.validation.valid!

      status, headers, body = @app.call(env)

      response = Esplanade::Response.new(request, status, body)
      response.validation.valid!

      [status, headers, body]
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
esplanade-1.6.0 lib/esplanade/middlewares/dangerous_middleware.rb
esplanade-1.5.0 lib/esplanade/middlewares/dangerous_middleware.rb
esplanade-1.4.0 lib/esplanade/middlewares/dangerous_middleware.rb
esplanade-1.3.0 lib/esplanade/middlewares/dangerous_middleware.rb
esplanade-1.2.1 lib/esplanade/middlewares/dangerous_middleware.rb
esplanade-1.2.0 lib/esplanade/middlewares/dangerous_middleware.rb