Sha256: f6d99db53ba322f7944ee5291cd43e06796ce8ad05447da72a724f7a872b83c2

Contents?: true

Size: 787 Bytes

Versions: 3

Compression:

Stored size: 787 Bytes

Contents

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

module Esplanade
  class CheckCustomResponseMiddleware
    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)

      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

3 entries across 3 versions & 1 rubygems

Version Path
esplanade-1.6.0 lib/esplanade/middlewares/check_custom_response_middleware.rb
esplanade-1.5.0 lib/esplanade/middlewares/check_custom_response_middleware.rb
esplanade-1.4.0 lib/esplanade/middlewares/check_custom_response_middleware.rb