Class: Esplanade::CheckCustomResponseMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/esplanade/middlewares/check_custom_response_middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, **params) ⇒ CheckCustomResponseMiddleware

Returns a new instance of CheckCustomResponseMiddleware.



7
8
9
10
# File 'lib/esplanade/middlewares/check_custom_response_middleware.rb', line 7

def initialize(app, **params)
  @app = app
  @documentation = Tomograph::Tomogram.new(Esplanade.configuration.params.merge(params))
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/esplanade/middlewares/check_custom_response_middleware.rb', line 12

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