method

call

Importance_0
v7.0.0 - Show latest stable - 0 notes - Class: ServerTiming
call(env) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File actionpack/lib/action_dispatch/middleware/server_timing.rb, line 13
    def call(env)
      events = []
      subscriber = ActiveSupport::Notifications.subscribe(/.*/) do |*args|
        events << ActiveSupport::Notifications::Event.new(*args)
      end

      status, headers, body = begin
        @app.call(env)
      ensure
        ActiveSupport::Notifications.unsubscribe(subscriber)
      end

      header_info = events.group_by(&:name).map do |event_name, events_collection|
        "#{event_name};dur=#{events_collection.sum(&:duration)}"
      end
      headers[SERVER_TIMING_HEADER] = header_info.join(", ")

      [ status, headers, body ]
    end
Register or log in to add new notes.