Class: Hatchet::Middleware

Inherits:
Object
  • Object
show all
Includes:
Hatchet
Defined in:
lib/hatchet/middleware.rb

Overview

Public: Middleware for making sure the nested diagnostic context is cleared between requests.

Constant Summary

Constants included from Hatchet

VERSION

Instance Method Summary collapse

Methods included from Hatchet

appenders, configuration, configure, included, #logger, registered, #to_yaml_properties

Constructor Details

#initialize(app) ⇒ Middleware

Public: Creates a new instance of the middleware, wrapping the given application.

app - The application to wrap.



14
15
16
# File 'lib/hatchet/middleware.rb', line 14

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Public: Calls the wrapped application with the given environment, ensuring the nested diagnostic context is cleared afterwards.

env - The enviroment Hash for the request.

Returns the status, headers, body Array returned by the wrapped application.



26
27
28
29
30
# File 'lib/hatchet/middleware.rb', line 26

def call(env)
  @app.call(env)
ensure
  log.ndc.clear!
end