Module: Datadog::AppSec::Contrib::Sinatra::DispatchPatch

Defined in:
lib/datadog/appsec/contrib/sinatra/patcher.rb

Overview

Hook into Base#dispatch!, which encompasses route filters

Instance Method Summary collapse

Instance Method Details

#dispatch!Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 52

def dispatch!
  env = @request.env

  context = env[Datadog::AppSec::Ext::CONTEXT_KEY]

  return super unless context

  # TODO: handle exceptions, except for super

  gateway_request = Gateway::Request.new(env)

  request_return, _gateway_request = Instrumentation.gateway.push('sinatra.request.dispatch', gateway_request) do
    super
  end

  request_return
end