Sha256: 41a870be49be3a33570198df401d0229c75815a3dd6a119aa34de37d347cefb7

Contents?: true

Size: 482 Bytes

Versions: 2

Compression:

Stored size: 482 Bytes

Contents

require 'grape'
require 'librato-rack'

module Librato
  module Grape
    class Middleware < ::Grape::Middleware::Base
      def initialize(app)
        @app = app
      end

      def call(env)
        req = ::Rack::Request.new(env)
        request_path = env['api.endpoint'].routes.first.route_path[1..-1].gsub("/", ".").sub(/\(\.:format\)\z/, "") 
        Librato.timing "#{req.request_method}.#{request_path}" do
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grape-librato-1.0.0 lib/grape-librato/middleware.rb
grape-librato-0.0.1 lib/grape-librato/middleware.rb